public boolean shouldPublish()

in src/main/java/com/cisco/gerrit/plugins/slack/message/CommentAddedMessageGenerator.java [59:94]


  public boolean shouldPublish() {
    if (!config.isEnabled() || !config.shouldPublishOnCommentAdded()) {
      return false;
    }

    try {
      ChangeAttribute change;
      change = event.change.get();
      if (config.getIgnorePrivatePatchSet() && Boolean.TRUE.equals(change.isPrivate)) {
        return false;
      }
      if (config.getIgnoreWorkInProgressPatchSet() && Boolean.TRUE.equals(change.wip)) {
        return false;
      }
    } catch (Exception e) {
      LOGGER.warn("Error checking private and work-in-progress status", e);
    }

    boolean result;
    result = true;

    try {
      Pattern pattern;
      pattern = Pattern.compile(config.getIgnoreCommentAuthor(), Pattern.DOTALL);

      Matcher matcher;
      matcher = pattern.matcher(event.author.get().username);

      // If the ignore pattern matches, publishing should not happen
      result = !matcher.matches();
    } catch (Exception e) {
      LOGGER.warn("The specified ignore-comment-author pattern was invalid", e);
    }

    return result;
  }