services.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:xivo-ctid-ng 作者: wazo-pbx 项目源码 文件源码
def send_message(self, request_body, user_uuid=None):
        from_xivo_uuid, from_ = self._build_from(request_body, user_uuid)
        to_xivo_uuid, to = self._build_to(request_body)
        alias = request_body['alias']
        msg = request_body['msg']
        self.contexts.add(from_, to, to_xivo_uuid=to_xivo_uuid, alias=alias)

        from_jid = self._build_jid(from_xivo_uuid, from_)
        to_jid = self._build_jid(to_xivo_uuid, to)
        try:
            self.mongooseim_client.send_message(from_jid, to_jid, msg)
        except HTTPError as e:
            raise MongooseIMException(self._xivo_uuid, e.response.status_code, e.response.reason)
        except RequestException as e:
            raise MongooseIMUnreachable(self._xivo_uuid, e)

        bus_event = ChatMessageSent((from_xivo_uuid, from_),
                                    (to_xivo_uuid, to),
                                    alias,
                                    msg)
        headers = {
            'user_uuid:{uuid}'.format(uuid=from_): True,
        }
        self._bus_publisher.publish(bus_event, headers=headers)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号