Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0384.py @ 2925:03a09e16bf28
plugin XEP-0384: wait for client to be ready if session is missing when onNewDevices is called
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Apr 2019 08:55:07 +0200 |
parents | 851c47cc4ae7 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2924:59aea54e74a8 | 2925:03a09e16bf28 |
---|---|
537 | 537 |
538 defer.returnValue(xmlui) | 538 defer.returnValue(xmlui) |
539 | 539 |
540 @defer.inlineCallbacks | 540 @defer.inlineCallbacks |
541 def profileConnected(self, client): | 541 def profileConnected(self, client): |
542 # FIXME: is _xep_0384_ready needed? can we use profileConnecting? | |
543 # Workflow should be checked | |
542 client._xep_0384_ready = defer.Deferred() | 544 client._xep_0384_ready = defer.Deferred() |
543 # we first need to get devices ids (including our own) | 545 # we first need to get devices ids (including our own) |
544 persistent_dict = persistent.LazyPersistentBinaryDict("XEP-0384", client.profile) | 546 persistent_dict = persistent.LazyPersistentBinaryDict("XEP-0384", client.profile) |
545 # all known devices of profile | 547 # all known devices of profile |
546 devices = yield self.getDevices(client) | 548 devices = yield self.getDevices(client) |
765 ## PEP node events callbacks | 767 ## PEP node events callbacks |
766 | 768 |
767 @defer.inlineCallbacks | 769 @defer.inlineCallbacks |
768 def onNewDevices(self, itemsEvent, profile): | 770 def onNewDevices(self, itemsEvent, profile): |
769 client = self.host.getClient(profile) | 771 client = self.host.getClient(profile) |
770 omemo_session = client._xep_0384_session | 772 try: |
773 omemo_session = client._xep_0384_session | |
774 except AttributeError: | |
775 yield client._xep_0384_ready | |
776 omemo_session = client._xep_0384_session | |
771 entity = itemsEvent.sender | 777 entity = itemsEvent.sender |
772 | 778 |
773 devices = self.parseDevices(itemsEvent.items) | 779 devices = self.parseDevices(itemsEvent.items) |
774 omemo_session.newDeviceList(entity, devices) | 780 omemo_session.newDeviceList(entity, devices) |
775 | 781 |