Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
e4343205 by lovetox at 2022-01-22T17:06:11+01:00
MUC: Add MucSubject struct
- - - - -
2 changed files:
- nbxmpp/modules/muc/muc.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/modules/muc/muc.py
=====================================
@@ -25,6 +25,7 @@ from nbxmpp.protocol import DataForm
from nbxmpp.protocol import DataField
from nbxmpp.protocol import NodeProcessed
from nbxmpp.protocol import StanzaMalformed
+from nbxmpp.structs import MucSubject
from nbxmpp.structs import StanzaHandler
from nbxmpp.const import InviteType
from nbxmpp.const import MessageType
@@ -79,9 +80,13 @@ class MUC(BaseModule):
ns=Namespace.MUC_USER,
priority=11),
StanzaHandler(name='message',
- callback=self._process_groupchat_message,
+ callback=self._process_message_before_decryption,
typ='groupchat',
priority=6),
+ StanzaHandler(name='message',
+ callback=self._process_message_after_decryption,
+ typ='groupchat',
+ priority=16),
StanzaHandler(name='message',
callback=self._process_mediated_invite,
typ='normal',
@@ -182,7 +187,7 @@ class MUC(BaseModule):
self._log.warning(stanza)
raise NodeProcessed
- def _process_groupchat_message(self, _client, stanza, properties):
+ def _process_message_before_decryption(self, _client, stanza, properties):
properties.from_muc = True
properties.muc_jid = properties.jid.new_as_bare()
properties.muc_nickname = properties.jid.resource
@@ -203,6 +208,13 @@ class MUC(BaseModule):
if address is not None:
properties.muc_ofrom = JID.from_string(address.getAttr('jid'))
+ def _process_message_after_decryption(self, _client, stanza, properties):
+ if properties.body is None and properties.subject:
+ properties.muc_subject = MucSubject(
+ text=properties.subject,
+ author=properties.muc_nickname,
+ timestamp=properties.user_timestamp)
+
def _process_message(self, _client, stanza, properties):
muc_user = stanza.getTag('x', namespace=Namespace.MUC_USER)
if muc_user is None:
=====================================
nbxmpp/structs.py
=====================================
@@ -130,6 +130,12 @@ class MucConfigResult(NamedTuple):
form: Optional[Any] = None
+class MucSubject(NamedTuple):
+ text: str
+ author: str
+ timestamp: float
+
+
class AffiliationResult(NamedTuple):
jid: JID
users: dict[JID, dict[str, str]]
@@ -957,6 +963,7 @@ class MessageProperties:
muc_decline = None
muc_user = None
muc_ofrom = None
+ muc_subject: Optional[MucSubject] = None
captcha: Optional[CaptchaData] = None
voice_request: Optional[VoiceRequest] = None
self_message: bool = False
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/e4343205805566cb67b2f804258ae9f2e02daa4e
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/e4343205805566cb67b2f804258ae9f2e02daa4e
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits