plugin identity: return resource for MUC room occupants' nicks + added avatar and avatar_basename.

This commit is contained in:
Goffi 2018-01-03 00:20:21 +01:00
commit a9e8a79445

View file

@ -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 @@ class Identity(object):
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):