Commit 1795473b authored by Philipp Hörist's avatar Philipp Hörist

Add muc_jid attribute to Message and Presence

Attribute contains a bare JID object if the Message or Presence is from a MUC
parent f39d0057
......@@ -97,6 +97,8 @@ class MUC:
if muc is None:
return
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
properties.muc_nickname = properties.jid.getResource()
def _process_muc_user_presence(self, _con, stanza, properties):
......@@ -104,6 +106,8 @@ class MUC:
if muc_user is None:
return
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
destroy = muc_user.getTag('destroy')
if destroy is not None:
......@@ -158,6 +162,8 @@ class MUC:
def _process_groupchat_message(self, _con, stanza, properties):
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
properties.muc_nickname = properties.jid.getResource() or None
muc_user = stanza.getTag('x', namespace=NS_MUC_USER)
......@@ -185,6 +191,8 @@ class MUC:
return
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
if not properties.jid.isBare:
return
......@@ -249,6 +257,8 @@ class MUC:
return
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
data = {}
......@@ -291,6 +301,9 @@ class MUC:
return
properties.voice_request = VoiceRequest(form=data_form)
properties.from_muc = True
properties.muc_jid = properties.jid.copy()
properties.muc_jid.setBare()
@call_on_response('_affiliation_received')
def get_affiliation(self, jid, affiliation):
......
......@@ -246,6 +246,7 @@ class MessageProperties:
self.http_auth = None
self.nickname = None
self.from_muc = False
self.muc_jid = None
self.muc_nickname = None
self.muc_status_codes = None
self.muc_private_message = False
......@@ -374,6 +375,7 @@ class PresenceProperties:
self.error = None
self.avatar_sha = None
self.avatar_state = AvatarState.IGNORE
self.muc_jid = None
self.muc_status_codes = None
self.muc_user = None
self.muc_nickname = None
......
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