diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-10-07 18:08:39 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-10-07 18:11:33 +0100 |
commit | 554ff650bff79488d259f32622dbc6b49842c243 (patch) | |
tree | 0ca47c1266b91829e74198de8be15fc0407270ab /poezio/core/handlers.py | |
parent | 232ef11630eed44d9f15b2e09b35bffb022c7afd (diff) | |
download | poezio-554ff650bff79488d259f32622dbc6b49842c243.tar.gz poezio-554ff650bff79488d259f32622dbc6b49842c243.tar.bz2 poezio-554ff650bff79488d259f32622dbc6b49842c243.tar.xz poezio-554ff650bff79488d259f32622dbc6b49842c243.zip |
Display contact avatar in the roster.
Implements XEP-0084 and XEP-0153.
Diffstat (limited to 'poezio/core/handlers.py')
-rw-r--r-- | poezio/core/handlers.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index a3d447bd..d8983041 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -355,6 +355,43 @@ class HandlerCore: else: self.core.refresh_window() + @asyncio.coroutine + def on_0084_avatar(self, msg): + jid = msg['from'].bare + contact = roster[jid] + if not contact: + return + log.debug('Received 0084 avatar update from %s', jid) + try: + metadata = msg['pubsub_event']['items']['item']['avatar_metadata']['items'] + except Exception: + return + for info in metadata: + if not info['url']: + try: + result = yield from self.core.xmpp['xep_0084'].retrieve_avatar(jid, + info['id'], + timeout=10) + contact.avatar = result['pubsub']['items']['item']['avatar_data']['value'] + except Exception: + log.exception('Failed retrieving 0084 data from %s:', jid) + return + log.debug('Received %s avatar: %s', jid, info['type']) + + @asyncio.coroutine + def on_vcard_avatar(self, pres): + jid = pres['from'].bare + log.debug('Received vCard avatar update from %s', jid) + try: + result = yield from self.core.xmpp['xep_0054'].get_vcard(jid, + cached=True, + timeout=10) + contact.avatar = result['vcard_temp']['PHOTO'] + except Exception: + log.exception('Failed retrieving vCard from %s:', jid) + return + log.debug('Received %s avatar: %s', jid, avatar['TYPE']) + def on_nick_received(self, message): """ Called when a pep notification for an user nickname |