aboutsummaryrefslogtreecommitdiffstats
path: root/slack
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-09-30 23:31:05 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit9c121f76db9285ffc06388bd899c88ce01a2c73a (patch)
treee838615a59254eb4f4815bccdc47138bca6f0c58 /slack
parenta9265419397256cb6c3bd944aab38b7f1d4a6990 (diff)
downloadwee-slack-9c121f76db9285ffc06388bd899c88ce01a2c73a.tar.gz
Get all reaction users in one request
Diffstat (limited to 'slack')
-rw-r--r--slack/slack_conversation.py12
-rw-r--r--slack/slack_message.py5
2 files changed, 15 insertions, 2 deletions
diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py
index 2d6fc3b..97fd85b 100644
--- a/slack/slack_conversation.py
+++ b/slack/slack_conversation.py
@@ -313,7 +313,17 @@ class SlackConversation(SlackBuffer):
]
sender_user_ids = [m.sender_user_id for m in messages if m.sender_user_id]
- self.workspace.users.initialize_items(sender_user_ids)
+ if self.display_reaction_nicks():
+ reaction_user_ids = [
+ user_id
+ for m in messages
+ for reaction in m.reactions
+ for user_id in reaction["users"]
+ ]
+ user_ids = sender_user_ids + reaction_user_ids
+ else:
+ user_ids = sender_user_ids
+ self.workspace.users.initialize_items(user_ids)
sender_bot_ids = [
m.sender_bot_id
diff --git a/slack/slack_message.py b/slack/slack_message.py
index 0771b60..36faa5f 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -217,6 +217,10 @@ class SlackMessage:
return await self.workspace.bots[self._message_json["bot_id"]]
@property
+ def reactions(self) -> List[SlackMessageReaction]:
+ return self._message_json.get("reactions", [])
+
+ @property
def priority(self) -> MessagePriority:
return MessagePriority.MESSAGE
@@ -603,7 +607,6 @@ class SlackMessage:
async def _create_reaction_string(self, reaction: SlackMessageReaction) -> str:
if self.conversation.display_reaction_nicks():
- # TODO: initialize_items?
users = await gather(
*(self.workspace.users[user_id] for user_id in reaction["users"])
)