# HG changeset patch # User Goffi # Date 1702501225 -3600 # Node ID 5d2de6c1156d0c4fc59ba387648cf117cf706d3e # Parent 7eda7cb8a15c7ffddd2336b00aa01a0e435f7d6f plugin XEP-0444: fix emoji check and ID used diff -r 7eda7cb8a15c -r 5d2de6c1156d libervia/backend/plugins/plugin_xep_0444.py --- a/libervia/backend/plugins/plugin_xep_0444.py Wed Dec 13 22:00:25 2023 +0100 +++ b/libervia/backend/plugins/plugin_xep_0444.py Wed Dec 13 22:00:25 2023 +0100 @@ -88,7 +88,7 @@ """ profile_id = self.host.memory.storage.profiles[client.profile] async with self.host.memory.storage.session() as session: - if message_elt.type == C.MESS_TYPE_GROUPCHAT: + if message_elt.getAttribute("type") == C.MESS_TYPE_GROUPCHAT: query = select(History).where( History.profile_id == profile_id, History.stanza_id == reaction_id ) @@ -126,8 +126,11 @@ reactions = set() for reaction_elt in reactions_elt.elements("reaction"): reaction = str(reaction_elt) - if not emoji.is_emoji(reaction): - log.warning(f"ignoring invalide reaction: {reaction_elt.toXml()}") + if ( + not emoji.purely_emoji(reaction) + or emoji.emoji_count(reaction) != 1 + ): + log.warning(f"Ignoring invalid reaction: {reaction_elt.toXml()}.") continue reactions.add(reaction) await self.update_history_reactions(client, history, from_jid, reactions) @@ -184,7 +187,7 @@ """Send the stanza containing the reactions @param dest_jid: recipient of the reaction - @param message_id: either or message's ID + @param message_id: either origin ID or stanza ID see https://xmpp.org/extensions/xep-0444.html#business-id """ message_elt = domish.Element((None, "message")) @@ -312,10 +315,10 @@ raise ValueError("message_id can't be empty") history = await self.get_history_from_uid(client, message_id) - if history.origin_id is not None: + if history.type == C.MESS_TYPE_GROUPCHAT: + mess_id = history.stanza_id + else: mess_id = history.origin_id - else: - mess_id = history.stanza_id if mess_id is None: raise exceptions.DataError(