def incoming(msg: dict, channel: MegatronChannel): from megatron.services import WorkspaceService platform_user = PlatformUser.objects.get(platform_id=msg["user"]) workspace_connection = WorkspaceService( channel.megatron_integration).get_connection(as_user=False) if msg.get("files", ""): msg = workspace_connection.build_img_attach(msg, platform_user) else: msg = { "username": platform_user.get_display_name(), "icon_url": platform_user.profile_image, "text": msg.get("text", None), "attachments": msg.get("attachments", None), } post_message_action = Action( ActionType.POST_MESSAGE, { "channel": channel.platform_channel_id, "message": msg }, ) response = workspace_connection.take_action(post_message_action) response.update({"watched_channel": True}) return response
def incoming(msg: dict, channel: MegatronChannel): from megatron.services import WorkspaceService platform_user = PlatformUser.objects.get(platform_id=msg['user']) workspace_connection = WorkspaceService( channel.megatron_integration).get_connection(as_user=False) if msg.get('files', ''): msg = workspace_connection.build_img_attach(msg, platform_user) else: msg = { 'username': platform_user.get_display_name(), 'icon_url': platform_user.profile_image, 'text': msg.get('text', None), 'attachments': msg.get('attachments', None) } post_message_action = Action(ActionType.POST_MESSAGE, { 'channel': channel.platform_channel_id, 'message': msg }) response = workspace_connection.take_action(post_message_action) response.update({'watched_channel': True}) return response