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

NIFI-13712 - Improve ListenSlack to catch channel join events #9230

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
review
  • Loading branch information
pvillard31 committed Sep 23, 2024
commit 7bff957aa9a5f40b4431be8083ba4e12bec54bb4
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public class ListenSlack extends AbstractProcessor {
"The Processor is to receive only slack messages that mention the bot user (App Mention Events)");
static final AllowableValue RECEIVE_COMMANDS = new AllowableValue("Receive Commands", "Receive Commands",
"The Processor is to receive Commands from Slack that are specific to your application. The Processor will not receive Message Events.");
static final AllowableValue MEMBER_JOINED_CHANNEL_EVENTS = new AllowableValue("Member Joined Channel", "Member Joined Channel",
"The Processor is to receive only events when a member is joining a channel. The Processor will not receive Message Events.");
static final AllowableValue RECEIVE_JOINED_CHANNEL_EVENTS = new AllowableValue("Receive Joined Channel Events", "Receive Joined Channel Events",
"The Processor is to receive only events when a member is joining a channel. The Processor will not receive Message Events.");


static PropertyDescriptor APP_TOKEN = new PropertyDescriptor.Builder()
Expand All @@ -123,7 +123,7 @@ public class ListenSlack extends AbstractProcessor {
.description("Specifies the type of Event that the Processor should respond to")
.required(true)
.defaultValue(RECEIVE_MENTION_EVENTS.getValue())
.allowableValues(RECEIVE_MENTION_EVENTS, RECEIVE_MESSAGE_EVENTS, RECEIVE_COMMANDS, MEMBER_JOINED_CHANNEL_EVENTS)
.allowableValues(RECEIVE_MENTION_EVENTS, RECEIVE_MESSAGE_EVENTS, RECEIVE_COMMANDS, RECEIVE_JOINED_CHANNEL_EVENTS)
.build();

final PropertyDescriptor RESOLVE_USER_DETAILS = new PropertyDescriptor.Builder()
Expand All @@ -136,7 +136,7 @@ public class ListenSlack extends AbstractProcessor {
.required(true)
.defaultValue("false")
.allowableValues("true", "false")
.dependsOn(EVENT_TYPE, RECEIVE_MESSAGE_EVENTS, RECEIVE_MENTION_EVENTS, MEMBER_JOINED_CHANNEL_EVENTS)
.dependsOn(EVENT_TYPE, RECEIVE_MESSAGE_EVENTS, RECEIVE_MENTION_EVENTS, RECEIVE_JOINED_CHANNEL_EVENTS)
.build();

static Relationship REL_SUCCESS = new Relationship.Builder()
Expand Down Expand Up @@ -185,7 +185,7 @@ public void establishWebsocketEndpoint(final ProcessContext context) throws Exce
// When there's an AppMention, we'll also get a MessageEvent. We need to handle this event, or we'll get warnings in the logs
// that no Event Handler is registered, and it will respond back to Slack with a 404. To avoid this, we just acknowledge the event.
slackApp.event(MessageEvent.class, (payload, ctx) -> ctx.ack());
} else if (context.getProperty(EVENT_TYPE).getValue().equals(MEMBER_JOINED_CHANNEL_EVENTS.getValue())) {
} else if (context.getProperty(EVENT_TYPE).getValue().equals(RECEIVE_JOINED_CHANNEL_EVENTS.getValue())) {
slackApp.event(MemberJoinedChannelEvent.class, this::handleEvent);
slackApp.event(MessageChannelJoinEvent.class, this::handleEvent);
// When there's an MemberJoinedChannel event, we'll also get a MessageEvent. We need to handle this event, or we'll get warnings in the logs
Expand Down