mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 13:24:54 +01:00
Slack - introduced caching
User and group query is expensive operation, this will speed up publishing of multiple instances
This commit is contained in:
parent
b167b971a2
commit
92f84518d7
1 changed files with 9 additions and 1 deletions
|
|
@ -62,8 +62,16 @@ class IntegrateSlackAPI(pyblish.api.InstancePlugin):
|
|||
client = SlackPython3Operations(token, self.log)
|
||||
|
||||
if "@" in message:
|
||||
if users is None:
|
||||
cache_key = "__cache_ids"
|
||||
slack_ids = instance.context.data.get(cache_key, None)
|
||||
if slack_ids is None:
|
||||
users, groups = client.get_users_and_groups()
|
||||
instance.context.data[cache_key] = {}
|
||||
instance.context.data[cache_key]["users"] = users
|
||||
instance.context.data[cache_key]["groups"] = groups
|
||||
else:
|
||||
users = slack_ids["users"]
|
||||
groups = slack_ids["groups"]
|
||||
message = self._translate_users(message, users, groups)
|
||||
|
||||
msg_id, file_ids = client.send_message(channel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue