plugin XEP-0045: Use disco as fallback for is_room:

If a room was not joined (e.g., due to failure), `is_room` was wrongly returning `False`.
Disco identity is now used as fallback to detect correctly is an entity is a room or not.
This changes makes `is_room` async, and by extension `get_bare_or_full` too.
This commit is contained in:
Goffi 2026-08-12 18:05:17 +02:00
commit dc9e3e98d5

View file

@ -254,7 +254,7 @@ class Identity:
cb_list.append(callback)
cb_list.sort(key=lambda c: c.priority, reverse=True)
def get_identity_jid(self, client, peer_jid):
async def get_identity_jid(self, client, peer_jid):
"""Return jid to use to set identity metadata
if it's a jid of a room occupant, full jid will be used
@ -266,8 +266,7 @@ class Identity:
return client.jid.userhostJID()
if self._m is None:
return peer_jid.userhostJID()
else:
return self._m.get_bare_or_full(client, peer_jid)
return await self._m.get_bare_or_full(client, peer_jid)
def check_type(self, metadata_name, value):
"""Check that type used for a metadata is the one declared in self.metadata"""
@ -306,7 +305,7 @@ class Identity:
@param use_cache: if False, cache won't be checked
@param prefilled_values: map of origin => value to use when `get_all` is set
"""
entity = self.get_identity_jid(client, entity)
entity = await self.get_identity_jid(client, entity)
try:
metadata = self.metadata[metadata_name]
except KeyError:
@ -398,7 +397,7 @@ class Identity:
@param entity(jid.JID, None): entity for which avatar is requested
None to use profile's jid
"""
entity = self.get_identity_jid(client, entity)
entity = await self.get_identity_jid(client, entity)
metadata = self.metadata[metadata_name]
data_filter = metadata.get("set_data_filter")
if data_filter is not None:
@ -448,7 +447,7 @@ class Identity:
This method may be called by plugins when an identity metadata is available.
@param origin: namespace of the plugin which is source of the metadata
"""
entity = self.get_identity_jid(client, entity)
entity = await self.get_identity_jid(client, entity)
if (entity, metadata_name) in client._identity_update_lock:
log.debug(f"update is locked for {entity}'s {metadata_name}")
return