core (memory): updateEntityData now accept a "silent" argument to avoid sending signal to frontends when updating an attribute with "signalOnUpdate" flag.
This commit is contained in:
parent
ec25ba82e1
commit
cdfb2c4dc6
8 changed files with 17 additions and 20 deletions
|
|
@ -107,7 +107,7 @@ class Discovery(object):
|
|||
def infosCb(disco_infos):
|
||||
cap_hash = self.generateHash(disco_infos)
|
||||
self.hashes[cap_hash] = disco_infos
|
||||
self.host.memory.updateEntityData(jid_, C.ENTITY_CAP_HASH, cap_hash, client.profile)
|
||||
self.host.memory.updateEntityData(jid_, C.ENTITY_CAP_HASH, cap_hash, profile_key=client.profile)
|
||||
return disco_infos
|
||||
d = client.disco.requestInfo(jid_)
|
||||
d.addCallback(infosCb)
|
||||
|
|
@ -135,7 +135,7 @@ class Discovery(object):
|
|||
except (KeyError, exceptions.UnknownEntityError):
|
||||
log.debug("Caching [%s] disco items" % jid_.full())
|
||||
items = yield client.disco.requestItems(jid_, nodeIdentifier)
|
||||
self.host.memory.updateEntityData(jid_, "DISCO_ITEMS", items, client.profile)
|
||||
self.host.memory.updateEntityData(jid_, "DISCO_ITEMS", items, profile_key=client.profile)
|
||||
else:
|
||||
items = yield client.disco.requestItems(jid_, nodeIdentifier)
|
||||
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ class Memory(object):
|
|||
@param profile_key: %(doc_profile_key)s
|
||||
"""
|
||||
presence_data = PresenceTuple(show, priority, statuses)
|
||||
self.updateEntityData(entity_jid, "presence", presence_data, profile_key)
|
||||
self.updateEntityData(entity_jid, "presence", presence_data, profile_key=profile_key)
|
||||
if entity_jid.resource and show != C.PRESENCE_UNAVAILABLE:
|
||||
# If a resource is available, bare jid should not have presence information
|
||||
try:
|
||||
|
|
@ -580,7 +580,7 @@ class Memory(object):
|
|||
full_jid.resource = resource
|
||||
yield full_jid
|
||||
|
||||
def updateEntityData(self, entity_jid, key, value, profile_key):
|
||||
def updateEntityData(self, entity_jid, key, value, silent=False, profile_key=C.PROF_KEY_NONE):
|
||||
"""Set a misc data for an entity
|
||||
|
||||
If key was registered with setSignalOnUpdate, a signal will be sent to frontends
|
||||
|
|
@ -588,6 +588,7 @@ class Memory(object):
|
|||
C.ENTITY_ALL for all entities (all resources + bare jids)
|
||||
@param key: key to set (eg: "type")
|
||||
@param value: value for this key (eg: "chatroom")
|
||||
@param silent(bool): if True, doesn't send signal to frontend, even there is a signal flag (see setSignalOnUpdate)
|
||||
@param profile_key: %(doc_profile_key)s
|
||||
"""
|
||||
profile_cache = self._getProfileCache(profile_key)
|
||||
|
|
@ -600,7 +601,7 @@ class Memory(object):
|
|||
entity_data = profile_cache.setdefault(jid_.userhostJID(),{}).setdefault(jid_.resource, {})
|
||||
|
||||
entity_data[key] = value
|
||||
if key in self._key_signals:
|
||||
if key in self._key_signals and not silent:
|
||||
if not isinstance(value, basestring):
|
||||
log.error(u"Setting a non string value ({}) for a key ({}) which has a signal flag".format(value, key))
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue