core: avoid to send presence unavailable signal when it's not necessary
This commit is contained in:
parent
95ad000f62
commit
c0f53629e5
1 changed files with 11 additions and 3 deletions
|
|
@ -392,10 +392,18 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
|||
if not self.host.trigger.point("presenceReceived", entity, "unavailable", 0, statuses, self.parent.profile):
|
||||
return
|
||||
|
||||
self.host.memory.setPresenceStatus(entity, C.PRESENCE_UNAVAILABLE, 0, statuses, self.parent.profile)
|
||||
|
||||
# now it's time to notify frontends
|
||||
self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
|
||||
# if the entity is not known yet in this session or is already unavailable, there is no need to send an unavailable signal
|
||||
try:
|
||||
presence = self.host.memory.getEntityDatum(entity, "presence", self.parent.profile)
|
||||
except KeyError:
|
||||
# the entity has not been seen yet in this session
|
||||
pass
|
||||
else:
|
||||
if presence.show != C.PRESENCE_UNAVAILABLE:
|
||||
self.host.bridge.presenceUpdate(entity.full(), C.PRESENCE_UNAVAILABLE, 0, statuses, self.parent.profile)
|
||||
|
||||
self.host.memory.setPresenceStatus(entity, C.PRESENCE_UNAVAILABLE, 0, statuses, self.parent.profile)
|
||||
|
||||
def available(self, entity=None, show=None, statuses=None, priority=None):
|
||||
"""Set a presence and statuses.
|
||||
|
|
|
|||
Loading…
Reference in a new issue