# HG changeset patch # User Goffi # Date 1514935221 -3600 # Node ID 65a6d2496504d69e8d1dd49d16b78da04bc90d93 # Parent 2cad04f38bac1a62239a46cc81259c6141065cc0 plugin identity: return resource for MUC room occupants' nicks + added avatar and avatar_basename. diff -r 2cad04f38bac -r 65a6d2496504 src/plugins/plugin_misc_identity.py --- a/src/plugins/plugin_misc_identity.py Wed Jan 03 00:18:31 2018 +0100 +++ b/src/plugins/plugin_misc_identity.py Wed Jan 03 00:20:21 2018 +0100 @@ -20,10 +20,12 @@ from sat.core.i18n import _ from sat.core.constants import Const as C +from sat.core import exceptions from sat.core.log import getLogger log = getLogger(__name__) from twisted.internet import defer from twisted.words.protocols.jabber import jid +import os.path PLUGIN_INFO = { @@ -69,11 +71,20 @@ roster_item = yield client.roster.getItem(jid_.userhostJID()) if roster_item is not None and roster_item.name: id_data[u'nick'] = roster_item.name + elif jid_.resource and self._v.isRoom(client, jid_): + id_data[u'nick'] = jid_.resource else: - # then vcard + # and finally then vcard nick = yield self._v.getNick(client, jid_) id_data[u'nick'] = nick if nick else jid_.user.capitalize() + try: + avatar_path = id_data[u'avatar'] = yield self._v.getAvatar(client, jid_, cache_only=False) + except exceptions.NotFound: + pass + else: + id_data[u'avatar_basename'] = os.path.basename(avatar_path) + defer.returnValue(id_data) def _setIdentity(self, id_data, profile):