@@ -80,12 +80,12 @@ <h1 class="title">Module <code>slack_bolt.request.internals</code></h1>
8080
8181
8282def extract_enterprise_id(payload: Dict[str, Any]) -> Optional[str]:
83- if payload.get("enterprise") is not None:
84- org = payload.get("enterprise")
83+ org = payload.get("enterprise")
84+ if org is not None:
8585 if isinstance(org, str):
8686 return org
8787 elif "id" in org:
88- return org.get("id") # type: ignore
88+ return org.get("id")
8989 if payload.get("authorizations") is not None and len(payload["authorizations"]) > 0:
9090 # To make Events API handling functioning also for shared channels,
9191 # we should use .authorizations[0].enterprise_id over .enterprise_id
@@ -131,26 +131,32 @@ <h1 class="title">Module <code>slack_bolt.request.internals</code></h1>
131131
132132
133133def extract_user_id(payload: Dict[str, Any]) -> Optional[str]:
134- if payload.get("user") is not None:
135- user = payload.get("user")
134+ user = payload.get("user")
135+ if user is not None:
136136 if isinstance(user, str):
137137 return user
138138 elif "id" in user:
139- return user.get("id") # type: ignore
139+ return user.get("id")
140140 if "user_id" in payload:
141141 return payload.get("user_id")
142142 if payload.get("event") is not None:
143143 return extract_user_id(payload["event"])
144+ if payload.get("message") is not None:
145+ # message_changed: body["event"]["message"]
146+ return extract_user_id(payload["message"])
147+ if payload.get("previous_message") is not None:
148+ # message_deleted: body["event"]["previous_message"]
149+ return extract_user_id(payload["previous_message"])
144150 return None
145151
146152
147153def extract_channel_id(payload: Dict[str, Any]) -> Optional[str]:
148- if payload.get("channel") is not None:
149- channel = payload.get("channel")
154+ channel = payload.get("channel")
155+ if channel is not None:
150156 if isinstance(channel, str):
151157 return channel
152158 elif "id" in channel:
153- return channel.get("id") # type: ignore
159+ return channel.get("id")
154160 if "channel_id" in payload:
155161 return payload.get("channel_id")
156162 if payload.get("event") is not None:
@@ -327,12 +333,12 @@ <h2 class="section-title" id="header-functions">Functions</h2>
327333< span > Expand source code</ span >
328334</ summary >
329335< pre > < code class ="python "> def extract_channel_id(payload: Dict[str, Any]) -> Optional[str]:
330- if payload.get("channel") is not None:
331- channel = payload.get("channel")
336+ channel = payload.get("channel")
337+ if channel is not None:
332338 if isinstance(channel, str):
333339 return channel
334340 elif "id" in channel:
335- return channel.get("id") # type: ignore
341+ return channel.get("id")
336342 if "channel_id" in payload:
337343 return payload.get("channel_id")
338344 if payload.get("event") is not None:
@@ -369,12 +375,12 @@ <h2 class="section-title" id="header-functions">Functions</h2>
369375< span > Expand source code</ span >
370376</ summary >
371377< pre > < code class ="python "> def extract_enterprise_id(payload: Dict[str, Any]) -> Optional[str]:
372- if payload.get("enterprise") is not None:
373- org = payload.get("enterprise")
378+ org = payload.get("enterprise")
379+ if org is not None:
374380 if isinstance(org, str):
375381 return org
376382 elif "id" in org:
377- return org.get("id") # type: ignore
383+ return org.get("id")
378384 if payload.get("authorizations") is not None and len(payload["authorizations"]) > 0:
379385 # To make Events API handling functioning also for shared channels,
380386 # we should use .authorizations[0].enterprise_id over .enterprise_id
@@ -458,16 +464,22 @@ <h2 class="section-title" id="header-functions">Functions</h2>
458464< span > Expand source code</ span >
459465</ summary >
460466< pre > < code class ="python "> def extract_user_id(payload: Dict[str, Any]) -> Optional[str]:
461- if payload.get("user") is not None:
462- user = payload.get("user")
467+ user = payload.get("user")
468+ if user is not None:
463469 if isinstance(user, str):
464470 return user
465471 elif "id" in user:
466- return user.get("id") # type: ignore
472+ return user.get("id")
467473 if "user_id" in payload:
468474 return payload.get("user_id")
469475 if payload.get("event") is not None:
470476 return extract_user_id(payload["event"])
477+ if payload.get("message") is not None:
478+ # message_changed: body["event"]["message"]
479+ return extract_user_id(payload["message"])
480+ if payload.get("previous_message") is not None:
481+ # message_deleted: body["event"]["previous_message"]
482+ return extract_user_id(payload["previous_message"])
471483 return None</ code > </ pre >
472484</ details >
473485</ dd >
0 commit comments