Skip to content

Commit ff9c796

Browse files
committed
version 1.14.2
1 parent dbdb2c5 commit ff9c796

File tree

7 files changed

+71
-25
lines changed

7 files changed

+71
-25
lines changed

docs/api-docs/slack_bolt/middleware/async_builtins.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7676
next: Callable[[], Awaitable[BoltResponse]],
7777
) -&gt; BoltResponse:
7878
auth_result = req.context.authorize_result
79-
if self._is_self_event(auth_result, req.context.user_id, req.body):
79+
# message events can have $.event.bot_id while it does not have its user_id
80+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
81+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
8082
self._debug_log(req.body)
8183
return await req.context.ack()
8284
else:

docs/api-docs/slack_bolt/middleware/ignoring_self_events/async_ignoring_self_events.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ <h1 class="title">Module <code>slack_bolt.middleware.ignoring_self_events.async_
4343
next: Callable[[], Awaitable[BoltResponse]],
4444
) -&gt; BoltResponse:
4545
auth_result = req.context.authorize_result
46-
if self._is_self_event(auth_result, req.context.user_id, req.body):
46+
# message events can have $.event.bot_id while it does not have its user_id
47+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
48+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
4749
self._debug_log(req.body)
4850
return await req.context.ack()
4951
else:
@@ -79,7 +81,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7981
next: Callable[[], Awaitable[BoltResponse]],
8082
) -&gt; BoltResponse:
8183
auth_result = req.context.authorize_result
82-
if self._is_self_event(auth_result, req.context.user_id, req.body):
84+
# message events can have $.event.bot_id while it does not have its user_id
85+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
86+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
8387
self._debug_log(req.body)
8488
return await req.context.ack()
8589
else:

docs/api-docs/slack_bolt/middleware/ignoring_self_events/ignoring_self_events.html

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,35 @@ <h1 class="title">Module <code>slack_bolt.middleware.ignoring_self_events.ignori
4949
next: Callable[[], BoltResponse],
5050
) -&gt; BoltResponse:
5151
auth_result = req.context.authorize_result
52-
if self._is_self_event(auth_result, req.context.user_id, req.body):
52+
# message events can have $.event.bot_id while it does not have its user_id
53+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
54+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
5355
self._debug_log(req.body)
5456
return req.context.ack()
5557
else:
5658
return next()
5759

5860
# -----------------------------------------
5961

60-
# Its an Events API event that isn&#39;t of type message,
62+
# It&#39;s an Events API event that isn&#39;t of type message,
6163
# but the user ID might match our own app. Filter these out.
6264
# However, some events still must be fired, because they can make sense.
6365
events_that_should_be_kept = [&#34;member_joined_channel&#34;, &#34;member_left_channel&#34;]
6466

6567
@classmethod
66-
def _is_self_event(cls, auth_result: AuthorizeResult, user_id: str, body: Dict[str, Any]):
68+
def _is_self_event(
69+
cls,
70+
auth_result: AuthorizeResult,
71+
user_id: Optional[str],
72+
bot_id: Optional[str],
73+
body: Dict[str, Any],
74+
):
6775
return (
6876
auth_result is not None
69-
and user_id is not None
70-
and user_id == auth_result.bot_user_id
77+
and (
78+
(user_id is not None and user_id == auth_result.bot_user_id)
79+
or (bot_id is not None and bot_id == auth_result.bot_id) # for bot_message events
80+
)
7181
and body.get(&#34;event&#34;) is not None
7282
and body.get(&#34;event&#34;, {}).get(&#34;type&#34;) not in cls.events_that_should_be_kept
7383
)
@@ -111,25 +121,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
111121
next: Callable[[], BoltResponse],
112122
) -&gt; BoltResponse:
113123
auth_result = req.context.authorize_result
114-
if self._is_self_event(auth_result, req.context.user_id, req.body):
124+
# message events can have $.event.bot_id while it does not have its user_id
125+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
126+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
115127
self._debug_log(req.body)
116128
return req.context.ack()
117129
else:
118130
return next()
119131

120132
# -----------------------------------------
121133

122-
# Its an Events API event that isn&#39;t of type message,
134+
# It&#39;s an Events API event that isn&#39;t of type message,
123135
# but the user ID might match our own app. Filter these out.
124136
# However, some events still must be fired, because they can make sense.
125137
events_that_should_be_kept = [&#34;member_joined_channel&#34;, &#34;member_left_channel&#34;]
126138

127139
@classmethod
128-
def _is_self_event(cls, auth_result: AuthorizeResult, user_id: str, body: Dict[str, Any]):
140+
def _is_self_event(
141+
cls,
142+
auth_result: AuthorizeResult,
143+
user_id: Optional[str],
144+
bot_id: Optional[str],
145+
body: Dict[str, Any],
146+
):
129147
return (
130148
auth_result is not None
131-
and user_id is not None
132-
and user_id == auth_result.bot_user_id
149+
and (
150+
(user_id is not None and user_id == auth_result.bot_user_id)
151+
or (bot_id is not None and bot_id == auth_result.bot_id) # for bot_message events
152+
)
133153
and body.get(&#34;event&#34;) is not None
134154
and body.get(&#34;event&#34;, {}).get(&#34;type&#34;) not in cls.events_that_should_be_kept
135155
)

docs/api-docs/slack_bolt/middleware/ignoring_self_events/index.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
7777
next: Callable[[], BoltResponse],
7878
) -&gt; BoltResponse:
7979
auth_result = req.context.authorize_result
80-
if self._is_self_event(auth_result, req.context.user_id, req.body):
80+
# message events can have $.event.bot_id while it does not have its user_id
81+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
82+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
8183
self._debug_log(req.body)
8284
return req.context.ack()
8385
else:
8486
return next()
8587

8688
# -----------------------------------------
8789

88-
# Its an Events API event that isn&#39;t of type message,
90+
# It&#39;s an Events API event that isn&#39;t of type message,
8991
# but the user ID might match our own app. Filter these out.
9092
# However, some events still must be fired, because they can make sense.
9193
events_that_should_be_kept = [&#34;member_joined_channel&#34;, &#34;member_left_channel&#34;]
9294

9395
@classmethod
94-
def _is_self_event(cls, auth_result: AuthorizeResult, user_id: str, body: Dict[str, Any]):
96+
def _is_self_event(
97+
cls,
98+
auth_result: AuthorizeResult,
99+
user_id: Optional[str],
100+
bot_id: Optional[str],
101+
body: Dict[str, Any],
102+
):
95103
return (
96104
auth_result is not None
97-
and user_id is not None
98-
and user_id == auth_result.bot_user_id
105+
and (
106+
(user_id is not None and user_id == auth_result.bot_user_id)
107+
or (bot_id is not None and bot_id == auth_result.bot_id) # for bot_message events
108+
)
99109
and body.get(&#34;event&#34;) is not None
100110
and body.get(&#34;event&#34;, {}).get(&#34;type&#34;) not in cls.events_that_should_be_kept
101111
)

docs/api-docs/slack_bolt/middleware/index.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,25 +242,35 @@ <h3>Inherited members</h3>
242242
next: Callable[[], BoltResponse],
243243
) -&gt; BoltResponse:
244244
auth_result = req.context.authorize_result
245-
if self._is_self_event(auth_result, req.context.user_id, req.body):
245+
# message events can have $.event.bot_id while it does not have its user_id
246+
bot_id = req.body.get(&#34;event&#34;, {}).get(&#34;bot_id&#34;)
247+
if self._is_self_event(auth_result, req.context.user_id, bot_id, req.body):
246248
self._debug_log(req.body)
247249
return req.context.ack()
248250
else:
249251
return next()
250252

251253
# -----------------------------------------
252254

253-
# Its an Events API event that isn&#39;t of type message,
255+
# It&#39;s an Events API event that isn&#39;t of type message,
254256
# but the user ID might match our own app. Filter these out.
255257
# However, some events still must be fired, because they can make sense.
256258
events_that_should_be_kept = [&#34;member_joined_channel&#34;, &#34;member_left_channel&#34;]
257259

258260
@classmethod
259-
def _is_self_event(cls, auth_result: AuthorizeResult, user_id: str, body: Dict[str, Any]):
261+
def _is_self_event(
262+
cls,
263+
auth_result: AuthorizeResult,
264+
user_id: Optional[str],
265+
bot_id: Optional[str],
266+
body: Dict[str, Any],
267+
):
260268
return (
261269
auth_result is not None
262-
and user_id is not None
263-
and user_id == auth_result.bot_user_id
270+
and (
271+
(user_id is not None and user_id == auth_result.bot_user_id)
272+
or (bot_id is not None and bot_id == auth_result.bot_id) # for bot_message events
273+
)
264274
and body.get(&#34;event&#34;) is not None
265275
and body.get(&#34;event&#34;, {}).get(&#34;type&#34;) not in cls.events_that_should_be_kept
266276
)

docs/api-docs/slack_bolt/version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="title">Module <code>slack_bolt.version</code></h1>
2828
<span>Expand source code</span>
2929
</summary>
3030
<pre><code class="python">&#34;&#34;&#34;Check the latest version at https://pypi.org/project/slack-bolt/&#34;&#34;&#34;
31-
__version__ = &#34;1.14.1&#34;</code></pre>
31+
__version__ = &#34;1.14.2&#34;</code></pre>
3232
</details>
3333
</section>
3434
<section>

slack_bolt/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Check the latest version at https://pypi.org/project/slack-bolt/"""
2-
__version__ = "1.14.1"
2+
__version__ = "1.14.2"

0 commit comments

Comments
 (0)