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:
Goffi 2015-02-09 21:39:51 +01:00
commit cdfb2c4dc6
8 changed files with 17 additions and 20 deletions

View file

@ -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: