diff options
-rw-r--r-- | slack/slack_api.py | 4 | ||||
-rw-r--r-- | slack/slack_workspace.py | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/slack/slack_api.py b/slack/slack_api.py index 890d4d9..9638e58 100644 --- a/slack/slack_api.py +++ b/slack/slack_api.py @@ -42,6 +42,10 @@ class SlackApiCommon: class SlackEdgeApi(SlackApiCommon): + @property + def is_available(self) -> bool: + return self.workspace.config.api_token.value.startswith("xoxc-") + async def _fetch_edgeapi(self, method: str, params: EdgeParams = {}): enterprise_id_part = ( f"{self.workspace.enterprise_id}/" if self.workspace.enterprise_id else "" diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py index d659317..a570658 100644 --- a/slack/slack_workspace.py +++ b/slack/slack_workspace.py @@ -216,6 +216,13 @@ class SlackWorkspace: await self._connect_ws(rtm_connect["url"]) + if not self.api.edgeapi.is_available: + usergroups = await self.api.fetch_usergroups_list() + for usergroup in usergroups["usergroups"]: + future = Future[SlackUsergroup]() + future.set_result(SlackUsergroup(self, usergroup)) + self.usergroups[usergroup["id"]] = future + users_conversations_response = await self.api.fetch_users_conversations( "public_channel,private_channel,mpim,im" ) |