diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-02 00:19:45 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 12ce8befda90d79ff3c1533770e38f865728482f (patch) | |
tree | 16bd450c00441b515519da69b88b9a40df8550d5 /slack/slack_api.py | |
parent | 91312364d70efaa3a0c6d4e8a15965383df5fcf7 (diff) | |
download | wee-slack-12ce8befda90d79ff3c1533770e38f865728482f.tar.gz |
Mark as read when switching away from buffer
Diffstat (limited to 'slack/slack_api.py')
-rw-r--r-- | slack/slack_api.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/slack/slack_api.py b/slack/slack_api.py index 3aa1d57..8e0b28a 100644 --- a/slack/slack_api.py +++ b/slack/slack_api.py @@ -14,6 +14,7 @@ from slack.util import chunked if TYPE_CHECKING: from slack_api.slack_bots_info import SlackBotInfoResponse, SlackBotsInfoResponse + from slack_api.slack_common import SlackGenericResponse from slack_api.slack_conversations_history import SlackConversationsHistoryResponse from slack_api.slack_conversations_info import SlackConversationsInfoResponse from slack_api.slack_conversations_members import SlackConversationsMembersResponse @@ -49,7 +50,7 @@ class SlackApiCommon: class SlackEdgeApi(SlackApiCommon): @property def is_available(self) -> bool: - return self.workspace.config.api_token.value.startswith("xoxc-") + return self.workspace.token_type == "session" async def _fetch_edgeapi(self, method: str, params: EdgeParams = {}): enterprise_id_part = ( @@ -248,3 +249,26 @@ class SlackApi(SlackApiCommon): if response["ok"] is False: raise SlackApiError(self.workspace, method, response) return response + + async def conversations_mark(self, conversation: SlackConversation, ts: SlackTs): + method = "conversations.mark" + params: Params = {"channel": conversation.id, "ts": ts} + response: SlackGenericResponse = await self._fetch(method, params) + if response["ok"] is False: + raise SlackApiError(self.workspace, method, response, params) + return response + + async def subscriptions_thread_mark( + self, conversation: SlackConversation, thread_ts: SlackTs, ts: SlackTs + ): + method = "subscriptions.thread.mark" + params: Params = { + "channel": conversation.id, + "thread_ts": thread_ts, + "ts": ts, + "read": 1, + } + response: SlackGenericResponse = await self._fetch(method, params) + if response["ok"] is False: + raise SlackApiError(self.workspace, method, response, params) + return response |