aboutsummaryrefslogtreecommitdiffstats
path: root/typings
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-12-11 21:15:51 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit3b98fbeff044299104f7d00a3c9b56d9a53b0df0 (patch)
tree6f38b4bcb90f125047eca166f8889b4fcd77e17a /typings
parent363950616419e0894196df08a47e5b084dcf8db4 (diff)
downloadwee-slack-3b98fbeff044299104f7d00a3c9b56d9a53b0df0.tar.gz
Support API restricted workspaces
Some enterprise workspaces are restricted in which API methods they can use, so we have to use some of the APIs the official web client uses (which can't be used by OAuth tokens) instead (mainly to initialize the workspace with client.userBoot and client.counts, and to connect to the websocket). This also has the benefit of being more performant, as the API methods the web client uses are more suited for creating a client than the official API methods. I think which API methods are restricted may be configured by the workspace admins, so it may not be the same for different workspaces, but for me it seems to be at least rtm.connect, users.conversations, conversations.list and conversations.members, so these are the ones I've changed to be conditional on the token type.
Diffstat (limited to 'typings')
-rw-r--r--typings/slack_api/slack_client_counts.pyi51
-rw-r--r--typings/slack_api/slack_client_userboot.pyi80
-rw-r--r--typings/slack_api/slack_users_conversations.pyi2
-rw-r--r--typings/slack_api/slack_users_info.pyi12
4 files changed, 138 insertions, 7 deletions
diff --git a/typings/slack_api/slack_client_counts.pyi b/typings/slack_api/slack_client_counts.pyi
new file mode 100644
index 0000000..81d758e
--- /dev/null
+++ b/typings/slack_api/slack_client_counts.pyi
@@ -0,0 +1,51 @@
+from __future__ import annotations
+
+from typing import List
+
+from slack_api.slack_common import SlackErrorResponse
+from typing_extensions import Literal, TypedDict, final
+
+@final
+class SlackClientCountsThreads(TypedDict):
+ has_unreads: bool
+ mention_count: int
+
+@final
+class SlackClientCountsConversation(TypedDict):
+ id: str
+ last_read: str
+ latest: str
+ updated: str
+ history_invalid: str
+ mention_count: int
+ has_unreads: bool
+
+@final
+class SlackClientCountsChannelBadges(TypedDict):
+ channels: int
+ dms: int
+ app_dms: int
+ thread_mentions: int
+ thread_unreads: int
+
+@final
+class SlackClientCountsAlerts(TypedDict):
+ pass
+
+@final
+class SlackClientCountsSaved(TypedDict):
+ uncompleted_count: int
+ uncompleted_overdue_count: int
+
+@final
+class SlackClientCountsSuccessResponse(TypedDict):
+ ok: Literal[True]
+ threads: SlackClientCountsThreads
+ channels: List[SlackClientCountsConversation]
+ mpims: List[SlackClientCountsConversation]
+ ims: List[SlackClientCountsConversation]
+ channel_badges: SlackClientCountsChannelBadges
+ alerts: SlackClientCountsAlerts
+ saved: SlackClientCountsSaved
+
+SlackClientCountsResponse = SlackClientCountsSuccessResponse | SlackErrorResponse
diff --git a/typings/slack_api/slack_client_userboot.pyi b/typings/slack_api/slack_client_userboot.pyi
new file mode 100644
index 0000000..973f589
--- /dev/null
+++ b/typings/slack_api/slack_client_userboot.pyi
@@ -0,0 +1,80 @@
+from __future__ import annotations
+
+from typing import Dict, List
+
+from slack_api.slack_common import SlackErrorResponse
+from slack_api.slack_conversations_info import SlackTopic
+from slack_api.slack_users_conversations import SlackUsersConversationsNotIm
+from slack_api.slack_users_info import SlackProfilePerson, SlackUserInfoCommon
+from slack_api.slack_users_prefs import SlackUsersPrefs
+from typing_extensions import Literal, NotRequired, TypedDict, final
+
+@final
+class SlackClientUserbootSelf(SlackUserInfoCommon):
+ profile: SlackProfilePerson
+ is_bot: Literal[False]
+ first_login: int
+ lob_sales_home_enabled: bool
+ manual_presence: Literal["active"]
+
+@final
+class SlackClientUserbootTeam(TypedDict):
+ id: str
+ name: str
+ domain: str
+ # Incomplete
+
+@final
+class SlackClientUserbootIm(TypedDict):
+ id: str
+ created: int
+ is_frozen: bool
+ is_archived: bool
+ is_im: Literal[True]
+ is_org_shared: bool
+ context_team_id: str
+ updated: int
+ is_shared: bool
+ user: str
+ last_read: str
+ latest: str
+ is_open: bool
+ topic: NotRequired[SlackTopic]
+
+@final
+class SlackClientUserbootSubteams(TypedDict):
+ self: List[str]
+
+@final
+class SlackClientUserbootSuccessResponse(TypedDict):
+ ok: Literal[True]
+ self: SlackClientUserbootSelf
+ team: SlackClientUserbootTeam
+ ims: List[SlackClientUserbootIm]
+ # workspaces: List[]
+ default_workspace: str
+ # account_types
+ # accept_tos_url
+ is_open: List[str]
+ # is_europe
+ # translations_cache_ts
+ # emoji_cache_ts
+ # app_commands_cache_ts
+ # cache_ts_version
+ # dnd
+ prefs: SlackUsersPrefs
+ subteams: SlackClientUserbootSubteams
+ # mobile_app_requires_upgrade
+ starred: List[str]
+ channels_priority: Dict[str, float]
+ read_only_channels: List[str]
+ non_threadable_channels: List[str]
+ thread_only_channels: List[str]
+ channels: List[SlackUsersConversationsNotIm]
+ # cache_version
+ slack_route: str
+ # auth_min_last_fetched
+ # can_access_client_v2
+ # links
+
+SlackClientUserbootResponse = SlackClientUserbootSuccessResponse | SlackErrorResponse
diff --git a/typings/slack_api/slack_users_conversations.pyi b/typings/slack_api/slack_users_conversations.pyi
index f3602c7..55dc0d6 100644
--- a/typings/slack_api/slack_users_conversations.pyi
+++ b/typings/slack_api/slack_users_conversations.pyi
@@ -50,7 +50,7 @@ class SlackUsersConversationsCommonNotIm(SlackUsersConversationsCommon):
class SlackUsersConversationsPublic(SlackUsersConversationsCommonNotIm):
is_mpim: Literal[False]
is_private: Literal[False]
- previous_names: List[str] # TODO: Check if private and mpim has this
+ previous_names: List[str]
@final
class SlackUsersConversationsPrivate(SlackUsersConversationsCommonNotIm):
diff --git a/typings/slack_api/slack_users_info.pyi b/typings/slack_api/slack_users_info.pyi
index cd493ed..3908588 100644
--- a/typings/slack_api/slack_users_info.pyi
+++ b/typings/slack_api/slack_users_info.pyi
@@ -40,12 +40,12 @@ class SlackProfileCommon(TypedDict):
is_custom_image: NotRequired[Optional[bool]]
huddle_state: NotRequired[Optional[str]]
huddle_state_expiration_ts: NotRequired[Optional[int]]
- image_24: str
- image_32: str
- image_48: str
- image_72: str
- image_192: str
- image_512: str
+ image_24: NotRequired[str]
+ image_32: NotRequired[str]
+ image_48: NotRequired[str]
+ image_72: NotRequired[str]
+ image_192: NotRequired[str]
+ image_512: NotRequired[str]
image_1024: NotRequired[str]
status_text_canonical: NotRequired[Optional[str]]
team: str