Dont notify about PMs from MUCs we are not joined
The server sends us carbons if one of our other resources has a conversation in a muc we are not joined. Instead we log the messages silently.
This commit is contained in:
parent
52fa57795a
commit
f30564c15c
2 changed files with 11 additions and 3 deletions
|
@ -176,8 +176,10 @@ class HelperEvent:
|
||||||
def _is_muc_pm(self, message):
|
def _is_muc_pm(self, message):
|
||||||
if self.muc_pm is not None:
|
if self.muc_pm is not None:
|
||||||
return self.muc_pm
|
return self.muc_pm
|
||||||
self.muc_pm = message.getTag(
|
self.muc_pm = False
|
||||||
'x', namespace=nbxmpp.NS_MUC_USER) is not None
|
muc_user = message.getTag('x', namespace=nbxmpp.NS_MUC_USER)
|
||||||
|
if muc_user is not None:
|
||||||
|
self.muc_pm = muc_user.getChildren() == []
|
||||||
return self.muc_pm
|
return self.muc_pm
|
||||||
|
|
||||||
class HttpAuthReceivedEvent(nec.NetworkIncomingEvent):
|
class HttpAuthReceivedEvent(nec.NetworkIncomingEvent):
|
||||||
|
@ -1599,6 +1601,7 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
self.forwarded = self.msg_obj.forwarded
|
self.forwarded = self.msg_obj.forwarded
|
||||||
self.sent = self.msg_obj.sent
|
self.sent = self.msg_obj.sent
|
||||||
self.conn = self.msg_obj.conn
|
self.conn = self.msg_obj.conn
|
||||||
|
self.muc_pm = self.msg_obj.muc_pm
|
||||||
self.popup = False
|
self.popup = False
|
||||||
self.msg_log_id = None # id in log database
|
self.msg_log_id = None # id in log database
|
||||||
self.attention = False # XEP-0224
|
self.attention = False # XEP-0224
|
||||||
|
|
|
@ -101,7 +101,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
if treat_as:
|
if treat_as:
|
||||||
obj.mtype = treat_as
|
obj.mtype = treat_as
|
||||||
pm = False
|
pm = False
|
||||||
if obj.gc_control and obj.resource:
|
if obj.muc_pm or (obj.gc_control and obj.resource):
|
||||||
# It's a Private message
|
# It's a Private message
|
||||||
pm = True
|
pm = True
|
||||||
obj.mtype = 'pm'
|
obj.mtype = 'pm'
|
||||||
|
@ -123,6 +123,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
additional_data=obj.additional_data,
|
additional_data=obj.additional_data,
|
||||||
stanza_id=obj.unique_id)
|
stanza_id=obj.unique_id)
|
||||||
|
|
||||||
|
if obj.muc_pm and not obj.gc_control:
|
||||||
|
# This is a carbon of a PM from a MUC we are not currently
|
||||||
|
# joined. We log it silently without notification.
|
||||||
|
return True
|
||||||
|
|
||||||
# Handle chat states
|
# Handle chat states
|
||||||
if contact and (not obj.forwarded or not obj.sent):
|
if contact and (not obj.forwarded or not obj.sent):
|
||||||
if self.control and self.control.type_id == \
|
if self.control and self.control.type_id == \
|
||||||
|
|
Loading…
Add table
Reference in a new issue