Philipp Hörist pushed to branch reactions at gajim / gajim
Commits:
512f76f6 by Philipp Hörist at 2024-05-10T18:09:32+02:00
new: Send reactions
- - - - -
4 changed files:
- gajim/common/modules/message.py
- gajim/common/modules/omemo.py
- gajim/common/modules/reactions.py
- gajim/common/structs.py
Changes:
=====================================
gajim/common/modules/message.py
=====================================
@@ -356,6 +356,10 @@ def build_message_stanza(self, message: OutgoingMessage)
-> nbxmpp.Message:
message.reply_data.fallback_start,
message.reply_data.fallback_end)
+ # XEP-0444
+ if message.reaction_data is not None:
+ stanza.setReactions(*message.reaction_data)
+
# XEP-0359
message.message_id = generate_id()
stanza.setID(message.message_id)
=====================================
gajim/common/modules/omemo.py
=====================================
@@ -85,6 +85,7 @@
('reply', Namespace.REPLY),
('fallback', Namespace.FALLBACK),
('origin-id', Namespace.SID),
+ ('reactions', Namespace.REACTIONS),
]
DeviceIdT = int
=====================================
gajim/common/modules/reactions.py
=====================================
@@ -7,7 +7,6 @@
from __future__ import annotations
from nbxmpp.namespaces import Namespace
-from nbxmpp.protocol import JID
from nbxmpp.protocol import Message
from nbxmpp.protocol import NodeProcessed
from nbxmpp.structs import MessageProperties
@@ -22,6 +21,7 @@
from gajim.common.modules.util import get_occupant_info
from gajim.common.storage.archive import models as mod
from gajim.common.structs import MessageType
+from gajim.common.structs import OutgoingMessage
class Reactions(BaseModule):
@@ -110,7 +110,23 @@ def _process_reaction(
)
)
- def send_reactions(self, jid: JID, reaction_id: str, reactions: list[str])
-> None:
+ def send_reaction(
+ self,
+ contact: types.ChatContactT,
+ reaction_id: str,
+ reactions: set[str],
+ ) -> None:
+
+ typ = 'groupchat' if contact.is_groupchat else 'chat'
+
+ message = OutgoingMessage(
+ account=self._account,
+ contact=contact,
+ text=None,
+ type_=typ,
+ reaction_data=(reaction_id, reactions),
+ play_sound=False
+ )
- # TODO
- pass
+ self._client.send_message(message)
+ self._log.info('Send %s: %s', reactions, contact.jid)
=====================================
gajim/common/structs.py
=====================================
@@ -94,6 +94,7 @@ def __init__(self,
attention: bool | None = None,
correct_id: str | None = None,
reply_data: ReplyData | None = None,
+ reaction_data: tuple[str, set[str]] | None = None,
oob_url: str | None = None,
nodes: Any | None = None,
play_sound: bool = True
@@ -129,6 +130,7 @@ def __init__(self,
self.attention = attention
self.correct_id = correct_id
self.reply_data = reply_data
+ self.reaction_data = reaction_data
self.oob_url = oob_url
self.nodes = nodes
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/512f76f64bcc477519367e6a79e7c6243c59f5be
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/512f76f64bcc477519367e6a79e7c6243c59f5be
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]