Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_watched.py @ 2820:7ab8684784c6
core: renamed presenceReceived to presence_reveiced + use "client" as first arguments instead of "profile"
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Mar 2019 12:12:50 +0100 |
parents | 003b8b4b56a7 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2819:fd45089b3a92 | 2820:7ab8684784c6 |
---|---|
60 | 60 |
61 def __init__(self, host): | 61 def __init__(self, host): |
62 log.info(_("Watched initialisation")) | 62 log.info(_("Watched initialisation")) |
63 self.host = host | 63 self.host = host |
64 host.memory.updateParams(self.params) | 64 host.memory.updateParams(self.params) |
65 host.trigger.add("presenceReceived", self._presenceReceivedTrigger) | 65 host.trigger.add("presence_received", self._presenceReceivedTrigger) |
66 | 66 |
67 def _presenceReceivedTrigger(self, entity, show, priority, statuses, profile): | 67 def _presenceReceivedTrigger(self, client, entity, show, priority, statuses): |
68 if show == C.PRESENCE_UNAVAILABLE: | 68 if show == C.PRESENCE_UNAVAILABLE: |
69 return True | 69 return True |
70 | 70 |
71 # we check that the previous presence was unavailable (no notification else) | 71 # we check that the previous presence was unavailable (no notification else) |
72 try: | 72 try: |
73 old_show = self.host.memory.getEntityDatum(entity, "presence", profile).show | 73 old_show = self.host.memory.getEntityDatum( |
74 entity, "presence", client.profile).show | |
74 except (KeyError, exceptions.UnknownEntityError): | 75 except (KeyError, exceptions.UnknownEntityError): |
75 old_show = C.PRESENCE_UNAVAILABLE | 76 old_show = C.PRESENCE_UNAVAILABLE |
76 | 77 |
77 if old_show == C.PRESENCE_UNAVAILABLE: | 78 if old_show == C.PRESENCE_UNAVAILABLE: |
78 watched = self.host.memory.getParamA(NAME, CATEGORY, profile_key=profile) | 79 watched = self.host.memory.getParamA( |
80 NAME, CATEGORY, profile_key=client.profile) | |
79 if entity in watched or entity.userhostJID() in watched: | 81 if entity in watched or entity.userhostJID() in watched: |
80 self.host.actionNew( | 82 self.host.actionNew( |
81 { | 83 { |
82 "xmlui": xml_tools.note( | 84 "xmlui": xml_tools.note( |
83 _(NOTIF).format(entity=entity.full()) | 85 _(NOTIF).format(entity=entity.full()) |
84 ).toXml() | 86 ).toXml() |
85 }, | 87 }, |
86 profile=profile, | 88 profile=client.profile, |
87 ) | 89 ) |
88 | 90 |
89 return True | 91 return True |