Example #1
0
 def rtm_event_open_conv(self):
     """ 打开会话,同步客户端,发送至RTM """
     # 1. 更新接接收者不同设备会话列表未读消息量
     # 2. 更新发送者对话框消息是否已读状态
     rtm_e = mc.LCEvent.OpenConv
     user_tid = pk_hashid_encode(self.usrid)
     touch_tid = pk_hashid_encode(self.touchid)
     content = dict(evt=rtm_e, cid=self.convid, usrtid=user_tid)
     agora_rtm_send_peer(content, [user_tid, touch_tid])
Example #2
0
 def rtm_event_call_reach(self):
     """ 通话触达,同步客户端,发送至RTM """
     if not self.is_call:
         return
     self.refresh_from_db()
     rtm_e = mc.LCEvent.ReachCall
     content = dict(
         type=self.msg_type, evt=rtm_e,
         mid=self.hid, cid=self.convid,
         reachd=self.get_reach_display(),
         reach=self.reach, summary=self.content,
     )
     sender_tid = pk_hashid_encode(self.sender)
     receiver_tid = pk_hashid_encode(self.receiver)
     agora_rtm_send_peer(content, [sender_tid, receiver_tid])
     return content
Example #3
0
 def rtm_event_new_msg(self):
     """ 发送至RTM """
     rtm_e = mc.LCEvent.NewMessage
     content = dict(
         type=self.msg_type, evt=rtm_e,
         mid=self.hid, cid=self.convid,
     )
     # 发送方靠页面回退来触发更新新消息
     # sender_tid = pk_hashid_encode(self.sender)
     receiver_tid = pk_hashid_encode(self.receiver)
     agora_rtm_send_peer(content, [receiver_tid])
Example #4
0
 def rtm_event_bill_reach(self, bill_hid):
     """ 通话账单推送,同步客户端,发送至RTM """
     if not self.is_call:
         return
     rtm_e = mc.LCEvent.BillPush
     content = dict(
         type=self.msg_type, evt=rtm_e,
         mid=self.hid, cid=self.convid,
         reach=self.reach, hid=bill_hid,
     )
     sender_tid = pk_hashid_encode(self.sender)
     agora_rtm_send_peer(content, [sender_tid])
     return content
Example #5
0
 def get(self, request, *args, **kwargs):
     contact = self.get_contact(kwargs)
     user = request.user
     contact.open_conv()
     conv = contact.conv_info
     last_hid = self.request.query_params.get('last', '')
     last_msg_id = self.check_last_msgid(conv.convid, last_hid)
     is_add, new_last = last_msg_id > 0, pk_hashid_encode(conv.last_id)
     msg_qs = conv.after_msg_qs(last_msg_id) if is_add else conv.show_msg_qs
     msgs = serializer.MessageSerializer(msg_qs,
                                         context={
                                             'user': user
                                         },
                                         many=True).data
     data = dict(count=conv.count, limit=Conversation.show_limit)
     data.update(last=new_last, add=is_add, msgs=reversed(msgs))
     return Response(data=data)
Example #6
0
 def hid(self):
     assert isinstance(self.pk, int)
     return pk_hashid_encode(self.pk)
Example #7
0
 def tid(self):
     """ 外部ID,加密HashID """
     hexid = pk_hashid_encode(self.bid)
     return hexid