Send timestamp with receipts (should help fix stream errors)
This commit is contained in:
parent
d9bd18013d
commit
ef50b4c1db
30
session.py
30
session.py
|
@ -201,10 +201,10 @@ class Session(YowsupApp):
|
|||
else:
|
||||
self.onPresenceUnavailable(number)
|
||||
def sendReadReceipts(self, buddy):
|
||||
for _id, _from, participant in self.recvMsgIDs:
|
||||
for _id, _from, participant, t in self.recvMsgIDs:
|
||||
if _from.split(u'@')[0] == buddy:
|
||||
self.sendReceipt(_id, _from, u'read', participant)
|
||||
self.recvMsgIDs.remove((_id, _from, participant))
|
||||
self.sendReceipt(_id, _from, 'read', participant, t)
|
||||
self.recvMsgIDs.remove((_id, _from, participant, t))
|
||||
self.logger.debug(u"Send read receipt to %s (ID: %s)", _from, _id)
|
||||
|
||||
# Called by superclass
|
||||
|
@ -276,8 +276,8 @@ class Session(YowsupApp):
|
|||
])
|
||||
buddy = _from.split(u'@')[0]
|
||||
messageContent = utils.softToUni(body)
|
||||
self.sendReceipt(_id, _from, None, participant)
|
||||
self.recvMsgIDs.append((_id, _from, participant))
|
||||
self.sendReceipt(_id, _from, None, participant, timestamp)
|
||||
self.recvMsgIDs.append((_id, _from, participant, timestamp))
|
||||
self.logger.info(u"Message received from %s to %s: %s (at ts=%s)",
|
||||
buddy, self.legacyName, messageContent, timestamp)
|
||||
if participant is not None: # Group message or broadcast
|
||||
|
@ -312,8 +312,8 @@ class Session(YowsupApp):
|
|||
else:
|
||||
self.sendMessageToXMPP(buddy, image.url, image.timestamp)
|
||||
self.sendMessageToXMPP(buddy, image.caption, image.timestamp)
|
||||
self.sendReceipt(image._id, image._from, None, image.participant)
|
||||
self.recvMsgIDs.append((image._id, image._from, image.participant))
|
||||
self.sendReceipt(image._id, image._from, None, image.participant, image.timestamp)
|
||||
self.recvMsgIDs.append((image._id, image._from, image.participant, image.timestamp))
|
||||
|
||||
|
||||
# Called by superclass
|
||||
|
@ -331,8 +331,8 @@ class Session(YowsupApp):
|
|||
self.sendGroupMessageToXMPP(buddy, partname, message, audio.timestamp)
|
||||
else:
|
||||
self.sendMessageToXMPP(buddy, message, audio.timestamp)
|
||||
self.sendReceipt(audio._id, audio._from, None, audio.participant)
|
||||
self.recvMsgIDs.append((audio._id, audio._from, audio.participant))
|
||||
self.sendReceipt(audio._id, audio._from, None, audio.participant, audio.timestamp)
|
||||
self.recvMsgIDs.append((audio._id, audio._from, audio.participant, audio.timestamp))
|
||||
|
||||
|
||||
# Called by superclass
|
||||
|
@ -351,8 +351,8 @@ class Session(YowsupApp):
|
|||
self.sendGroupMessageToXMPP(buddy, partname, message, video.timestamp)
|
||||
else:
|
||||
self.sendMessageToXMPP(buddy, message, video.timestamp)
|
||||
self.sendReceipt(video._id, video._from, None, video.participant)
|
||||
self.recvMsgIDs.append((video._id, video._from, video.participant))
|
||||
self.sendReceipt(video._id, video._from, None, video.participant, video.timestamp)
|
||||
self.recvMsgIDs.append((video._id, video._from, video.participant, video.timestamp))
|
||||
|
||||
|
||||
def onLocation(self, location):
|
||||
|
@ -382,8 +382,8 @@ class Session(YowsupApp):
|
|||
if url is not None:
|
||||
self.sendMessageToXMPP(buddy, url, location.timestamp)
|
||||
self.sendMessageToXMPP(buddy, latlong, location.timestamp)
|
||||
self.sendReceipt(location._id, location._from, None, location.participant)
|
||||
self.recvMsgIDs.append((location._id, location._from, location.participant))
|
||||
self.sendReceipt(location._id, location._from, None, location.participant, location.timestamp)
|
||||
self.recvMsgIDs.append((location._id, location._from, location.participant, location.timestamp))
|
||||
|
||||
|
||||
|
||||
|
@ -405,8 +405,8 @@ class Session(YowsupApp):
|
|||
self.sendMessageToXMPP(buddy, message, timestamp)
|
||||
# self.sendMessageToXMPP(buddy, card_data)
|
||||
#self.transferFile(buddy, str(name), card_data)
|
||||
self.sendReceipt(_id, _from, None, participant)
|
||||
self.recvMsgIDs.append((_id, _from, participant))
|
||||
self.sendReceipt(_id, _from, None, participant, timestamp)
|
||||
self.recvMsgIDs.append((_id, _from, participant, timestamp))
|
||||
|
||||
|
||||
def transferFile(self, buddy, name, data):
|
||||
|
|
|
@ -153,7 +153,7 @@ class YowsupApp(object):
|
|||
"""
|
||||
self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_DISCONNECT))
|
||||
|
||||
def sendReceipt(self, _id, _from, read, participant):
|
||||
def sendReceipt(self, _id, _from, read, participant, t):
|
||||
"""
|
||||
Send a receipt (delivered: double-tick, read: blue-ticks)
|
||||
|
||||
|
@ -162,8 +162,10 @@ class YowsupApp(object):
|
|||
- _from: jid of person who sent the message
|
||||
- read: ('read' or None) None is just delivered, 'read' is read
|
||||
- participant
|
||||
- t: The time the original message was sent.
|
||||
"""
|
||||
receipt = OutgoingReceiptProtocolEntity(_id, _from, read, participant)
|
||||
self.logger.debug(u'Sending receipt to whatsapp: %s', [_id, _from, read, participant, t])
|
||||
receipt = OutgoingReceiptProtocolEntity(_id, _from, read, participant, t=t)
|
||||
self.sendEntity(receipt)
|
||||
|
||||
def downloadMedia(self, url, onSuccess = None, onFailure = None):
|
||||
|
|
Loading…
Reference in a new issue