Skip to content

Commit

Permalink
Check comment is from regular user before running GH action
Browse files Browse the repository at this point in the history
Signed-off-by: stianst <[email protected]>
  • Loading branch information
stianst committed Mar 7, 2024
1 parent 070d3ad commit 97a154f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/org/keycloak/gh/bot/BugActionsOnComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

import io.quarkiverse.githubapp.event.IssueComment;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
import org.keycloak.gh.bot.labels.Action;
import org.keycloak.gh.bot.labels.Kind;
import org.keycloak.gh.bot.utils.Labels;
import org.kohsuke.github.GHEventPayload;
import org.kohsuke.github.GHUser;

import java.io.IOException;

public class BugActionsOnComment {

private static final Logger logger = Logger.getLogger(BugActionsOnComment.class);

@Inject
BugActions bugActions;

void onCommentCreated(@IssueComment.Created GHEventPayload.IssueComment payload) throws IOException {
if (Labels.hasLabel(payload.getIssue(), Kind.BUG.toLabel())) {
Action action = getAction(payload.getComment().getBody());
if (payload.getSender().isMemberOf(payload.getOrganization())) {

GHUser sender = payload.getSender();
if (sender.getType().equals("User") && sender.isMemberOf(payload.getOrganization())) {
bugActions.runAction(action, payload.getIssue());
}
}
Expand Down

0 comments on commit 97a154f

Please sign in to comment.