Philipp Hörist pushed to branch master at gajim / gajim
Commits:
f30564c1 by Philipp Hörist at 2018-02-22T21:42:49+01:00
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.
- - - - -
994244c9 by Philipp Hörist at 2018-02-22T22:03:55+01:00
MAM: Check muc#user namespace before we disco
1. Check if the message has the muc#user namespace
2. Check if we have this jid already in the DB
3. Last resort disco the jid
- - - - -
2 changed files:
- gajim/common/connection_handlers_events.py
- gajim/session.py
Changes:
=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -176,8 +176,10 @@ class HelperEvent:
def _is_muc_pm(self, message):
if self.muc_pm is not None:
return self.muc_pm
- self.muc_pm = message.getTag(
- 'x', namespace=nbxmpp.NS_MUC_USER) is not None
+ self.muc_pm = False
+ 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
class HttpAuthReceivedEvent(nec.NetworkIncomingEvent):
@@ -1125,6 +1127,8 @@ class MamGcMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
:stanza: Complete stanza Node
:forwarded: Forwarded Node
:result: Result Node
+ :muc_pm: True, if this is a MUC PM
+ propagated to MamDecryptedMessageReceivedEvent
'''
self._set_base_event_vars_as_attributes(base_event)
self.additional_data = {}
@@ -1205,23 +1209,27 @@ class MamDecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
if self.groupchat:
return True
- self.is_pm = app.logger.jid_is_room_jid(self.with_.getStripped())
- if self.is_pm is None:
- # Check if this event is triggered after a disco, so we dont
- # run into an endless loop
- if hasattr(self, 'disco'):
- log.error('JID not known even after sucessful disco')
+ if not self.muc_pm:
+ # muc_pm = False, means only there was no muc#user namespace
+ # This could still be a muc pm, we check the database if we
+ # know this jid. If not we disco it.
+ self.muc_pm = app.logger.jid_is_room_jid(self.with_.getStripped())
+ if self.muc_pm is None:
+ # Check if this event is triggered after a disco, so we dont
+ # run into an endless loop
+ if hasattr(self, 'disco'):
+ log.error('JID not known even after sucessful disco')
+ return
+ # we don't know this JID, we need to disco it.
+ server = self.with_.getDomain()
+ if server not in self.conn.mam_awaiting_disco_result:
+ self.conn.mam_awaiting_disco_result[server] = [self]
+ self.conn.discoverInfo(server)
+ else:
+ self.conn.mam_awaiting_disco_result[server].append(self)
return
- # we don't know this JID, we need to disco it.
- server = self.with_.getDomain()
- if server not in self.conn.mam_awaiting_disco_result:
- self.conn.mam_awaiting_disco_result[server] = [self]
- self.conn.discoverInfo(server)
- else:
- self.conn.mam_awaiting_disco_result[server].append(self)
- return
- if self.is_pm:
+ if self.muc_pm:
self.with_ = str(self.with_)
else:
self.with_ = self.with_.getStripped()
@@ -1599,6 +1607,7 @@ class DecryptedMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.forwarded = self.msg_obj.forwarded
self.sent = self.msg_obj.sent
self.conn = self.msg_obj.conn
+ self.muc_pm = self.msg_obj.muc_pm
self.popup = False
self.msg_log_id = None # id in log database
self.attention = False # XEP-0224
=====================================
gajim/session.py
=====================================
--- a/gajim/session.py
+++ b/gajim/session.py
@@ -101,7 +101,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if treat_as:
obj.mtype = treat_as
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
pm = True
obj.mtype = 'pm'
@@ -123,6 +123,11 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
additional_data=obj.additional_data,
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
if contact and (not obj.forwarded or not obj.sent):
if self.control and self.control.type_id == \
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/52fa57795ac04fb273c3686f05adb3d76…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/52fa57795ac04fb273c3686f05adb3d76…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
1fbc6a23 by Philipp Hörist at 2018-02-21T23:09:30+01:00
Tag MUC PMs
This gives the server the chance to react accordingly without applying
much logic.
Also it makes it easier for us to recognize MUC PMs in MAM querys
- - - - -
1 changed file:
- gajim/common/connection.py
Changes:
=====================================
gajim/common/connection.py
=====================================
--- a/gajim/common/connection.py
+++ b/gajim/common/connection.py
@@ -64,6 +64,7 @@ from gajim.common import exceptions
from gajim.common import check_X509
from gajim.common.connection_handlers import *
from gajim.common.helpers import version_condition
+from gajim.common.contacts import GC_Contact
from gajim.gtkgui_helpers import get_action
@@ -373,6 +374,10 @@ class CommonConnection:
contact = app.contacts.get_contact_with_highest_priority(
self.name, obj.jid)
+ # Mark Message as MUC PM
+ if isinstance(contact, GC_Contact):
+ msg_iq.setTag('x', namespace=nbxmpp.NS_MUC_USER)
+
# chatstates - if peer supports xep85, send chatstates
# please note that the only valid tag inside a message containing a
# <body> tag is the active event
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/1fbc6a2304b9066555ac367949bdc2e90d…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/1fbc6a2304b9066555ac367949bdc2e90d…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
70e0bcc5 by Philipp Hörist at 2018-02-21T23:01:47+01:00
Pass jid as string to find_stanza_id()
- - - - -
1 changed file:
- gajim/common/connection_handlers_events.py
Changes:
=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -1281,7 +1281,7 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
if type_ == 'groupchat':
archive_jid = self.stanza.getFrom().getStripped()
else:
- archive_jid = self.conn.get_own_jid()
+ archive_jid = self.conn.get_own_jid().getStripped()
if app.logger.find_stanza_id(account,
archive_jid,
self.unique_id,
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/70e0bcc5db144c2954c7cad077e9083f5f…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/70e0bcc5db144c2954c7cad077e9083f5f…
You're receiving this email because of your account on dev.gajim.org.