plugin XEP-0444: fix emoji check and ID used
This commit is contained in:
parent
b571b0d6e2
commit
133fe9c6fe
1 changed files with 10 additions and 7 deletions
|
|
@ -88,7 +88,7 @@ class XEP_0444:
|
|||
"""
|
||||
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 @@ class XEP_0444:
|
|||
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 @@ class XEP_0444:
|
|||
"""Send the <message> stanza containing the reactions
|
||||
|
||||
@param dest_jid: recipient of the reaction
|
||||
@param message_id: either <origin-id> 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 @@ class XEP_0444:
|
|||
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:
|
||||
mess_id = history.origin_id
|
||||
else:
|
||||
if history.type == C.MESS_TYPE_GROUPCHAT:
|
||||
mess_id = history.stanza_id
|
||||
else:
|
||||
mess_id = history.origin_id
|
||||
|
||||
if mess_id is None:
|
||||
raise exceptions.DataError(
|
||||
|
|
|
|||
Loading…
Reference in a new issue