-
Notifications
You must be signed in to change notification settings - Fork 399
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
Fixed the issue with member joined\left channel event not firing for own bot #236
Fixed the issue with member joined\left channel event not firing for own bot #236
Conversation
…own bot. Added tests for ignoreSelf middleware
subtype: 'bot_message', | ||
bot_id: fakeBotUserId, | ||
}, | ||
} as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I wasn't able to provide the correct type here :(
If someone could help, it would be great!
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 59.95% 61.94% +1.98%
==========================================
Files 7 7
Lines 492 494 +2
Branches 136 136
==========================================
+ Hits 295 306 +11
+ Misses 169 163 -6
+ Partials 28 25 -3
Continue to review full report at Codecov.
|
…iring-for-own-bot
src/middleware/builtin.ts
Outdated
@@ -231,7 +231,11 @@ export function ignoreSelf(): Middleware<AnyMiddlewareArgs> { | |||
} | |||
|
|||
// Its an Events API event that isn't of type message, but the user ID might match our own app. Filter these out. | |||
if (botUserId !== undefined && args.event.user === botUserId) { | |||
// However, some events still must be fired, because they can make sense. | |||
const eventsWhichShouldNotBeFilteredOut = ['member_joined_channel', 'member_left_channel']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const eventsWhichShouldNotBeFilteredOut = ['member_joined_channel', 'member_left_channel']; | |
const eventsWhichShouldBeKept = [ | |
'member_joined_channel', | |
'member_left_channel', | |
]; |
src/middleware/builtin.ts
Outdated
if (botUserId !== undefined && args.event.user === botUserId) { | ||
// However, some events still must be fired, because they can make sense. | ||
const eventsWhichShouldNotBeFilteredOut = ['member_joined_channel', 'member_left_channel']; | ||
const isEventShouldBeSkipped = !eventsWhichShouldNotBeFilteredOut.includes(args.event.type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isEventShouldBeSkipped = !eventsWhichShouldNotBeFilteredOut.includes(args.event.type); | |
const isEventShouldBeSkipped = !eventsWhichShouldBeKept.includes(args.event.type); |
I didn't like the double negative 🤔 this might be more readable...
…iring-for-own-bot
…iring-for-own-bot
…iring-for-own-bot
…iring-for-own-bot
assert(fakeNext.notCalled); | ||
}); | ||
|
||
it('should filter an event out, because it matches our own app and shouldn\'t be retained', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the same test as above?
i just want to say this PR is super awesome! |
Summary
This PR fixes issue #225 related to
member_joined_channel
(and alsomember_left_channel
) events which are not fired for own bot.Plus, I covered with unit tests
ignoreSelf()
middleware from https://github.com/slackapi/bolt/blob/522e70b381cf3d18a88b7ca271dcfb4f0ce1be9b/src/middleware/builtin.ts#L205Requirements (place an
x
in each[ ]
)