comparison src/plugins/plugin_xep_0054.py @ 2462:2cad04f38bac

plugin XEP-0054: return always False in isRoom is plugin XEP-0045 is not available + raise NotFound if avatar is requested for a MUC room (not the occupants, the room itself)
author Goffi <goffi@goffi.org>
date Wed, 03 Jan 2018 00:18:31 +0100
parents 8b37a62336c3
children 0046283a285d
comparison
equal deleted inserted replaced
2461:34cb8b713370 2462:2cad04f38bac
96 96
97 @param entity_jid(jid.JID): full or bare jid of the entity check 97 @param entity_jid(jid.JID): full or bare jid of the entity check
98 @return (bool): True if the bare jid of the entity is a room jid 98 @return (bool): True if the bare jid of the entity is a room jid
99 """ 99 """
100 try: 100 try:
101 self.host.plugins['XEP-0045'].checkRoomJoined(client, entity_jid.userhostJID()) 101 muc_plg = self.host.plugins['XEP-0045']
102 except KeyError:
103 return False
104
105 try:
106 muc_plg.checkRoomJoined(client, entity_jid.userhostJID())
102 except exceptions.NotFound: 107 except exceptions.NotFound:
103 return False 108 return False
104 else: 109 else:
105 return True 110 return True
106 111
354 @param cache_only(bool): if False, will request vCard if avatar is 359 @param cache_only(bool): if False, will request vCard if avatar is
355 not in cache 360 not in cache
356 @param hash_only(bool): if True only return hash, not full path 361 @param hash_only(bool): if True only return hash, not full path
357 @raise exceptions.NotFound: no avatar found 362 @raise exceptions.NotFound: no avatar found
358 """ 363 """
364 if not entity.resource and self.isRoom(client, entity):
365 raise exceptions.NotFound
359 entity = self.getBareOrFull(client, entity) 366 entity = self.getBareOrFull(client, entity)
360 full_path = None 367 full_path = None
361 368
362 try: 369 try:
363 # we first check if we have avatar in cache 370 # we first check if we have avatar in cache