Skip to content

Commit

Permalink
Add support for conversations.join
Browse files Browse the repository at this point in the history
Signed-off-by: Ygal Blum <[email protected]>
  • Loading branch information
ygalblum committed Jul 10, 2024
1 parent 6b13d71 commit 7ab8505
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions slack_server_mock/servers/http/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,25 @@ def post(self):
While the documentation states that this is a GET command, the SDK calls PUT
"""
self._handle()


class ConversationsJoinHandler(BaseSlackHandler): # pylint: disable=W0223
""" Handler for conversations.join endpoint """
def post(self):
""" Handle POST request """
if not self._is_request_valid():
return

arg = self.request.body.decode("utf-8").split('=')
if not (len(arg) == 2 and arg[0] == "channel"):
self.set_status(400)
self.write({"error": "Invalid argument"})
return

channels = [
channel for channel in global_injector.get(SlackServer).channels if channel['id'] == arg[1]
]
if len(channels) == 0:
self.write({"ok": False, "error": "channel_not_found"})
else:
self.write({"ok": True, "channel": channels[0]})
1 change: 1 addition & 0 deletions slack_server_mock/servers/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, settings: Settings) -> None:
(r"/apps.connections.open", handler.AppsConnectionsOpenHandler),
(r"/api.test", handler.ApiTestHandler),
(r"/chat.postMessage", handler.ChatPostMessageHandler),
(r"/conversations.join", handler.ConversationsJoinHandler),
(r"/conversations.list", handler.ConversationsListHandler),
]
)
Expand Down

0 comments on commit 7ab8505

Please sign in to comment.