comparison src/memory/memory.py @ 1392:c7082457d03f

memory, plugin XEP-0045: getMainResource returns None when asking a MUC entity + fixes /whois on a MUC (bare) entity
author souliane <souliane@mailoo.org>
date Wed, 25 Mar 2015 15:28:02 +0100
parents 3a20312d4012
children 069ad98b360d
comparison
equal deleted inserted replaced
1391:1276e6a0716b 1392:c7082457d03f
512 @param profile_key: %(doc_profile_key)s 512 @param profile_key: %(doc_profile_key)s
513 @return (unicode): main resource or None 513 @return (unicode): main resource or None
514 """ 514 """
515 if entity_jid.resource: 515 if entity_jid.resource:
516 raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid)) 516 raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid))
517 try:
518 if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key):
519 return None # MUC rooms have no main resource
520 except KeyError: # plugin not found
521 pass
517 resources = self.getAllResources(entity_jid, profile_key) 522 resources = self.getAllResources(entity_jid, profile_key)
518 priority_resources = [] 523 priority_resources = []
519 for resource in resources: 524 for resource in resources:
520 full_jid = copy.copy(entity_jid) 525 full_jid = copy.copy(entity_jid)
521 full_jid.resource = resource 526 full_jid.resource = resource