Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check comment is from regular user before running GH action #43

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading