Commit e4343205 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

MUC: Add MucSubject struct

parent 548e9895
Pipeline #9115 failed with stages
in 33 seconds
......@@ -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:
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment