Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0054.py @ 2060:d44360763262
plugin XEP-0054: renamed isInRoom to isRoom as the method only tell if the entity belong to a MUC
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 09 Sep 2016 23:54:33 +0200 |
parents | b99bd02ea643 |
children | ee9621d92cb9 |
comparison
equal
deleted
inserted
replaced
2059:9dd76a5b63ba | 2060:d44360763262 |
---|---|
107 x_elt.addElement('photo', content=avatar_hash) | 107 x_elt.addElement('photo', content=avatar_hash) |
108 presence_elt.addChild(x_elt) | 108 presence_elt.addChild(x_elt) |
109 | 109 |
110 return True | 110 return True |
111 | 111 |
112 def isInRoom(self, client, entity_jid): | 112 def isRoom(self, client, entity_jid): |
113 """Tell if an full jid is a member of a room | 113 """Tell if a jid is a MUC one |
114 | 114 |
115 @param entity_jid(jid.JID): full jid of the entity | 115 @param entity_jid(jid.JID): full or bare jid of the entity check |
116 @return (bool): True if the bare jid of the entity is a room jid | 116 @return (bool): True if the bare jid of the entity is a room jid |
117 """ | 117 """ |
118 try: | 118 try: |
119 self.host.plugins['XEP-0045'].checkRoomJoined(client, entity_jid.userhostJID()) | 119 self.host.plugins['XEP-0045'].checkRoomJoined(client, entity_jid.userhostJID()) |
120 except exceptions.NotFound: | 120 except exceptions.NotFound: |
152 @param jid_(jid.JID): jid of the owner of the vcard | 152 @param jid_(jid.JID): jid of the owner of the vcard |
153 @param name(str): name of the item which changed | 153 @param name(str): name of the item which changed |
154 @param value(unicode): new value of the item | 154 @param value(unicode): new value of the item |
155 """ | 155 """ |
156 if jid_.resource: | 156 if jid_.resource: |
157 if not self.isInRoom(client, jid_): | 157 if not self.isRoom(client, jid_): |
158 # VCard are retrieved with bare jid | 158 # VCard are retrieved with bare jid |
159 # but MUC room is a special case | 159 # but MUC room is a special case |
160 jid_ = jid.userhostJID() | 160 jid_ = jid.userhostJID() |
161 | 161 |
162 self.host.memory.updateEntityData(jid_, name, value, profile_key=client.profile) | 162 self.host.memory.updateEntityData(jid_, name, value, profile_key=client.profile) |
170 | 170 |
171 @param entity_jid: target contact | 171 @param entity_jid: target contact |
172 @param name: name of the value ('nick' or 'avatar') | 172 @param name: name of the value ('nick' or 'avatar') |
173 @return: wanted value or None""" | 173 @return: wanted value or None""" |
174 if entity_jid.resource: | 174 if entity_jid.resource: |
175 if not self.isInRoom(client, entity_jid): | 175 if not self.isRoom(client, entity_jid): |
176 # VCard are retrieved with bare jid | 176 # VCard are retrieved with bare jid |
177 # but MUC room is a special case | 177 # but MUC room is a special case |
178 entity_jid = jid.userhostJID() | 178 entity_jid = jid.userhostJID() |
179 try: | 179 try: |
180 data = self.host.memory.getEntityData(entity_jid, [name], client.profile) | 180 data = self.host.memory.getEntityData(entity_jid, [name], client.profile) |
375 | 375 |
376 Check for avatar information, and get VCard if needed | 376 Check for avatar information, and get VCard if needed |
377 @param presend(domish.Element): <presence/> stanza | 377 @param presend(domish.Element): <presence/> stanza |
378 """ | 378 """ |
379 from_jid = jid.JID(presence['from']) | 379 from_jid = jid.JID(presence['from']) |
380 if from_jid.resource and not self.plugin_parent.isInRoom(self.parent, from_jid): | 380 if from_jid.resource and not self.plugin_parent.isRoom(self.parent, from_jid): |
381 from_jid = from_jid.userhostJID() | 381 from_jid = from_jid.userhostJID() |
382 #FIXME: wokkel's data_form should be used here | 382 #FIXME: wokkel's data_form should be used here |
383 try: | 383 try: |
384 x_elt = presence.elements(NS_VCARD_UPDATE, 'x').next() | 384 x_elt = presence.elements(NS_VCARD_UPDATE, 'x').next() |
385 except StopIteration: | 385 except StopIteration: |