comparison sat/plugins/plugin_xep_0313.py @ 3011:93da7c6f8e0c

plugin XEP-0198: retrieve missing messages + send buffered ones on hot reconnection: Missing one2one messages are now retrieved with MAM on hot reconnection, and buffered ones (which have most probably not been received by the server) are resent at the end of the reconnection workflow. IQ results are not re-sent on hot reconnection, as they don't make sense anymore with a new session. fix 330
author Goffi <goffi@goffi.org>
date Wed, 17 Jul 2019 09:28:35 +0200
parents 32b6893240e0
children 1f74cd0f22c3
comparison
equal deleted inserted replaced
3010:e6806aaab16d 3011:93da7c6f8e0c
71 "MAMGet", ".plugin", in_sign='sss', 71 "MAMGet", ".plugin", in_sign='sss',
72 out_sign='(a(sdssa{ss}a{ss}sa{ss})a{ss}s)', method=self._getArchives, 72 out_sign='(a(sdssa{ss}a{ss}sa{ss})a{ss}s)', method=self._getArchives,
73 async=True) 73 async=True)
74 74
75 @defer.inlineCallbacks 75 @defer.inlineCallbacks
76 def profileConnected(self, client): 76 def resume(self, client):
77 """Retrieve one2one messages received since the last we have in local storage"""
77 stanza_id_data = yield self.host.memory.storage.getPrivates( 78 stanza_id_data = yield self.host.memory.storage.getPrivates(
78 mam.NS_MAM, [KEY_LAST_STANZA_ID], profile=client.profile) 79 mam.NS_MAM, [KEY_LAST_STANZA_ID], profile=client.profile)
79 stanza_id = stanza_id_data.get(KEY_LAST_STANZA_ID) 80 stanza_id = stanza_id_data.get(KEY_LAST_STANZA_ID)
80 if stanza_id is None: 81 if stanza_id is None:
81 log.info(u"can't retrieve last stanza ID, checking history") 82 log.info(u"can't retrieve last stanza ID, checking history")
139 if not count: 140 if not count:
140 log.info(_(u"We have received no message while offline")) 141 log.info(_(u"We have received no message while offline"))
141 else: 142 else:
142 log.info(_(u"We have received {num_mess} message(s) while offline.") 143 log.info(_(u"We have received {num_mess} message(s) while offline.")
143 .format(num_mess=count)) 144 .format(num_mess=count))
145
146 def profileConnected(self, client):
147 return self.resume(client)
144 148
145 def getHandler(self, client): 149 def getHandler(self, client):
146 mam_client = client._mam = SatMAMClient(self) 150 mam_client = client._mam = SatMAMClient(self)
147 return mam_client 151 return mam_client
148 152