Mercurial > libervia-pubsub
comparison sat_pubsub/privilege.py @ 348:d1f63ae1eaf4
privilege: added isSubscribedFrom method to check if an entity has presence subscription from an other entity.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 27 Aug 2017 20:26:38 +0200 |
parents | ff8aff4c9b79 |
children |
comparison
equal
deleted
inserted
replaced
347:f33406fcab5c | 348:d1f63ae1eaf4 |
---|---|
141 iq["to"] = to_jid.userhost() | 141 iq["to"] = to_jid.userhost() |
142 d = iq.send() | 142 d = iq.send() |
143 d.addCallback(processRoster) | 143 d.addCallback(processRoster) |
144 return d | 144 return d |
145 | 145 |
146 def _isSubscribedFrom(self, roster, entity, roster_owner_jid): | |
147 try: | |
148 return roster[entity.userhostJID()].subscriptionFrom | |
149 except KeyError: | |
150 return False | |
151 | |
152 def isSubscribedFrom(self, entity, roster_owner_jid): | |
153 """Check if entity has presence subscription from roster_owner_jid | |
154 | |
155 @param entity(jid.JID): entity to check subscription to | |
156 @param roster_owner_jid(jid.JID): owner of the roster to check | |
157 @return D(bool): True if entity has a subscription from roster_owner_jid | |
158 """ | |
159 d = self.getRoster(roster_owner_jid) | |
160 d.addCallback(self._isSubscribedFrom, entity, roster_owner_jid) | |
161 return d | |
162 | |
146 ## message ## | 163 ## message ## |
147 | 164 |
148 def sendMessage(self, priv_message, to_jid=None): | 165 def sendMessage(self, priv_message, to_jid=None): |
149 """ Send privileged message (in the name of the server) | 166 """Send privileged message (in the name of the server) |
150 | 167 |
151 @param priv_message(domish.Element): privileged message | 168 @param priv_message(domish.Element): privileged message |
152 @param to_jid(jid.JID, None): main message destinee | 169 @param to_jid(jid.JID, None): main message destinee |
153 None to use our own server | 170 None to use our own server |
154 """ | 171 """ |