summaryrefslogtreecommitdiff
path: root/poezio/bookmarks.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-01-29 12:05:01 +0100
committerLink Mauve <linkmauve@linkmauve.fr>2021-02-03 15:22:09 +0100
commitf5ad5199aeaa020e0d6a723341cd578a53c10850 (patch)
treedc487945e8a92985948c55c7d27526afdd50d459 /poezio/bookmarks.py
parent262583133e4965977b8340eb9ae125f7ad5c1751 (diff)
downloadpoezio-f5ad5199aeaa020e0d6a723341cd578a53c10850.tar.gz
poezio-f5ad5199aeaa020e0d6a723341cd578a53c10850.tar.bz2
poezio-f5ad5199aeaa020e0d6a723341cd578a53c10850.tar.xz
poezio-f5ad5199aeaa020e0d6a723341cd578a53c10850.zip
Use async properly on session start
Diffstat (limited to 'poezio/bookmarks.py')
-rw-r--r--poezio/bookmarks.py45
1 files changed, 18 insertions, 27 deletions
diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py
index d95e8fd5..f62f67ce 100644
--- a/poezio/bookmarks.py
+++ b/poezio/bookmarks.py
@@ -246,46 +246,37 @@ class BookmarkList:
if config.get('use_remote_bookmarks'):
self.save_remote(xmpp, _cb)
- def get_pep(self, xmpp, callback):
+ async def get_pep(self, xmpp):
"""Add the remotely stored bookmarks via pep to the list."""
+ iq = await xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0223')
+ for conf in iq['pubsub']['items']['item']['bookmarks'][
+ 'conferences']:
+ if isinstance(conf, URL):
+ continue
+ bookm = Bookmark.parse(conf)
+ self.append(bookm)
+ return iq
- def _cb(iq):
- if iq['type'] == 'result':
- for conf in iq['pubsub']['items']['item']['bookmarks'][
- 'conferences']:
- if isinstance(conf, URL):
- continue
- b = Bookmark.parse(conf)
- self.append(b)
- if callback:
- callback(iq)
-
- xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0223', callback=_cb)
-
- def get_privatexml(self, xmpp, callback):
+ async def get_privatexml(self, xmpp):
"""
Fetch the remote bookmarks stored via privatexml.
"""
- def _cb(iq):
- if iq['type'] == 'result':
- for conf in iq['private']['bookmarks']['conferences']:
- b = Bookmark.parse(conf)
- self.append(b)
- if callback:
- callback(iq)
-
- xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0049', callback=_cb)
+ iq = await xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0049')
+ for conf in iq['private']['bookmarks']['conferences']:
+ bookm = Bookmark.parse(conf)
+ self.append(bookm)
+ return iq
- def get_remote(self, xmpp, information, callback):
+ async def get_remote(self, xmpp, information):
"""Add the remotely stored bookmarks to the list."""
if xmpp.anon or not any(self.available_storage.values()):
information('No remote bookmark storage available', 'Warning')
return
if self.preferred == 'pep':
- self.get_pep(xmpp, callback=callback)
+ return await self.get_pep(xmpp)
else:
- self.get_privatexml(xmpp, callback=callback)
+ return await self.get_privatexml(xmpp)
def get_local(self):
"""Add the locally stored bookmarks to the list."""