diff 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
line wrap: on
line diff
--- a/src/memory/memory.py	Wed Mar 25 15:21:17 2015 +0100
+++ b/src/memory/memory.py	Wed Mar 25 15:28:02 2015 +0100
@@ -514,6 +514,11 @@
         """
         if entity_jid.resource:
             raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid))
+        try:
+            if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key):
+                return None  # MUC rooms have no main resource
+        except KeyError:  # plugin not found
+            pass
         resources = self.getAllResources(entity_jid, profile_key)
         priority_resources = []
         for resource in resources: