plugin identity: return resource for MUC room occupants' nicks + added avatar and avatar_basename.
This commit is contained in:
parent
284b2e2ca7
commit
a9e8a79445
1 changed files with 12 additions and 1 deletions
|
|
@ -20,10 +20,12 @@
|
||||||
|
|
||||||
from sat.core.i18n import _
|
from sat.core.i18n import _
|
||||||
from sat.core.constants import Const as C
|
from sat.core.constants import Const as C
|
||||||
|
from sat.core import exceptions
|
||||||
from sat.core.log import getLogger
|
from sat.core.log import getLogger
|
||||||
log = getLogger(__name__)
|
log = getLogger(__name__)
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.words.protocols.jabber import jid
|
from twisted.words.protocols.jabber import jid
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
PLUGIN_INFO = {
|
PLUGIN_INFO = {
|
||||||
|
|
@ -69,11 +71,20 @@ class Identity(object):
|
||||||
roster_item = yield client.roster.getItem(jid_.userhostJID())
|
roster_item = yield client.roster.getItem(jid_.userhostJID())
|
||||||
if roster_item is not None and roster_item.name:
|
if roster_item is not None and roster_item.name:
|
||||||
id_data[u'nick'] = 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:
|
else:
|
||||||
# then vcard
|
# and finally then vcard
|
||||||
nick = yield self._v.getNick(client, jid_)
|
nick = yield self._v.getNick(client, jid_)
|
||||||
id_data[u'nick'] = nick if nick else jid_.user.capitalize()
|
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)
|
defer.returnValue(id_data)
|
||||||
|
|
||||||
def _setIdentity(self, id_data, profile):
|
def _setIdentity(self, id_data, profile):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue