Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-06-18 17:28:47 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-06-18 22:30:24 +0300
commit752be7bdb85932c5adc8714918c66637ea9faff7 (patch)
treeffa192299c8fafec63900c75592a354e2788b165
parenta96ca2430e50fddfb4da19d00f3a1519d42e8331 (diff)
feat: MessageProperties: Add remote_jid attribute
-rw-r--r--nbxmpp/modules/message.py23
-rw-r--r--nbxmpp/modules/muc/muc.py7
-rw-r--r--nbxmpp/structs.py1
3 files changed, 11 insertions, 20 deletions
diff --git a/nbxmpp/modules/message.py b/nbxmpp/modules/message.py
index 4036487..1af46e9 100644
--- a/nbxmpp/modules/message.py
+++ b/nbxmpp/modules/message.py
@@ -48,6 +48,9 @@ class BaseMessage(BaseModule):
else:
properties.jid = stanza.getFrom()
+ self._parse_if_private_message(stanza, properties)
+
+ properties.remote_jid = self._determine_remote_jid(properties)
properties.from_ = stanza.getFrom()
properties.to = stanza.getTo()
properties.id = stanza.getID()
@@ -58,26 +61,20 @@ class BaseMessage(BaseModule):
if properties.type.is_error:
properties.error = error_factory(stanza)
- def _determine_remote_jid(self, stanza, properties) -> None:
- if properties.type.is_groupchat:
- return
+ def _determine_remote_jid(self, properties):
+ if properties.is_muc_pm:
+ return properties.jid
+ return properties.jid.new_as_bare()
+
+ def _parse_if_private_message(self, stanza, properties) -> None:
muc_user = stanza.getTag('x', namespace=Namespace.MUC_USER)
- if muc_user is not None:
+ if muc_user is None:
return
- occupant_id = stanza.getTagAttr('occupant-id',
- 'id',
- namespace=Namespace.OCCUPANT_ID)
-
- properties.occupant_id = occupant_id
-
- # MUC Private message
if (properties.type.is_chat or
properties.type.is_error and
not muc_user.getChildren()):
properties.muc_private_message = True
- return
-
def _process_message_after_base(self, _client, stanza, properties):
# This handler runs after decryption handlers had the chance
diff --git a/nbxmpp/modules/muc/muc.py b/nbxmpp/modules/muc/muc.py
index 700a236..c7c66a9 100644
--- a/nbxmpp/modules/muc/muc.py
+++ b/nbxmpp/modules/muc/muc.py
@@ -245,13 +245,6 @@ class MUC(BaseModule):
properties.occupant_id = occupant_id
- # MUC Private message
- if (properties.type.is_chat or
- properties.type.is_error and
- not muc_user.getChildren()):
- properties.muc_private_message = True
- return
-
if properties.is_muc_invite_or_decline:
return
diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py
index 717d9d4..d21cce8 100644
--- a/nbxmpp/structs.py
+++ b/nbxmpp/structs.py
@@ -971,6 +971,7 @@ class MessageProperties:
from_: Optional[JID] = None
to: Optional[JID] = None
jid: Optional[JID] = None
+ remote_jid: Optional[JID] = None
subject = None
body: Optional[str] = None
thread: Optional[str] = None