Mercurial > libervia-backend
diff src/memory/memory.py @ 1970:200cd707a46d
plugin XEP-0045, quick_frontend + primitivus (chat): cleaning of XEP-0045 (first pass):
- bridge methods/signals now all start with "muc" to follow new convention
- internal method use client instead of profile to follow new convention
- removed excetpions from plugin XEP-0045 in favor of core.exceptions, NotReady added
- cleaned/simplified several part of the code. checkClient removed as it is not needed anymore
- self.clients map removed, muc data are now stored directly in client
- getRoomEntityNick and getRoomNicksOfUsers are removed as they don't look sane.
/!\ This break all room game plugins for the moment
- use of uuid4 instead of uuid1 for getUniqueName, as host ID and current time are used for uuid1
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jun 2016 21:45:11 +0200 |
parents | a2bc5089c2eb |
children | b536dd121da1 |
line wrap: on
line diff
--- a/src/memory/memory.py Fri Jun 24 22:41:28 2016 +0200 +++ b/src/memory/memory.py Mon Jun 27 21:45:11 2016 +0200 @@ -635,25 +635,25 @@ return available def _getMainResource(self, jid_s, profile_key): + client = self.host.getClient(profile_key) jid_ = jid.JID(jid_s) - return self.getMainResource(jid_, profile_key) or "" + return self.getMainResource(client, jid_) or "" - def getMainResource(self, entity_jid, profile_key): + def getMainResource(self, client, entity_jid): """Return the main resource used by an entity @param entity_jid: bare entity jid - @param profile_key: %(doc_profile_key)s @return (unicode): main resource or None """ 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): + if self.host.plugins["XEP-0045"].isJoinedRoom(client, entity_jid): return None # MUC rooms have no main resource except KeyError: # plugin not found pass try: - resources = self.getAllResources(entity_jid, profile_key) + resources = self.getAllResources(entity_jid, client.profile) except exceptions.UnknownEntityError: log.warning(u"Entity is not in cache, we can't find any resource") return None @@ -662,7 +662,7 @@ full_jid = copy.copy(entity_jid) full_jid.resource = resource try: - presence_data = self.getEntityDatum(full_jid, "presence", profile_key) + presence_data = self.getEntityDatum(full_jid, "presence", client.profile) except KeyError: log.debug(u"No presence information for {}".format(full_jid)) continue