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.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
17fc8ff9 by Philipp Hörist at 2018-02-21T19:23:26+01:00
Limit deduplication to correct archive
We limit the search to non-groupchat messages because a stanza id
is only unique within an archive
- - - - -
0c7f1937 by Philipp Hörist at 2018-02-21T22:09:13+01:00
Fix duplicates for self messages and MUC PMs
Fixes #8812
- - - - -
015d99ea by Philipp Hörist at 2018-02-21T22:21:35+01:00
Print correct archive jid in log message
- - - - -
2 changed files:
- gajim/common/connection_handlers_events.py
- gajim/common/logger.py
Changes:
=====================================
gajim/common/connection_handlers_events.py
=====================================
--- a/gajim/common/connection_handlers_events.py
+++ b/gajim/common/connection_handlers_events.py
@@ -163,6 +163,23 @@ class HelperEvent:
if forwarded is not None:
return forwarded.getTag('message', protocol=True)
+ def _is_self_message(self, message):
+ if self.self_message is not None:
+ return self.self_message
+ own_jid = self.conn.get_own_jid()
+ frm = message.getFrom()
+ to = message.getTo()
+ # If 'to' is not set we assume own jid
+ self.self_message = frm.bareMatch(to or own_jid)
+ return self.self_message
+
+ 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
+ return self.muc_pm
+
class HttpAuthReceivedEvent(nec.NetworkIncomingEvent):
name = 'http-auth-received'
base_network_events = []
@@ -1015,6 +1032,8 @@ class MamMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.encrypted = False
self.groupchat = False
self.nick = None
+ self.self_message = None
+ self.muc_pm = None
def generate(self):
account = self.conn.name
@@ -1081,6 +1100,11 @@ class MamMessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
def get_unique_id(self):
stanza_id = self.get_stanza_id(self.result, query=True)
+
+ if self._is_self_message(self.msg_) or self._is_muc_pm(self.msg_):
+ origin_id = self.msg_.getOriginID()
+ return stanza_id, origin_id
+
if self.conn.get_own_jid().bareMatch(self.msg_.getFrom()):
# message we sent
origin_id = self.msg_.getOriginID()
@@ -1217,6 +1241,8 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.forwarded = False
self.sent = False
self.encrypted = False
+ self.self_message = None
+ self.muc_pm = None
account = self.conn.name
if self.stanza.getFrom() == self.conn.get_own_jid(warn=True):
@@ -1250,11 +1276,16 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.unique_id = self.get_unique_id()
# Check groupchat messages for duplicates,
# We do this because of MUC History messages
- if self.stanza.getType() == 'groupchat':
+ type_ = self.stanza.getType()
+ if type_ == 'groupchat' or self.self_message or self.muc_pm:
+ if type_ == 'groupchat':
+ archive_jid = self.stanza.getFrom().getStripped()
+ else:
+ archive_jid = self.conn.get_own_jid()
if app.logger.find_stanza_id(account,
- self.stanza.getFrom().getStripped(),
+ archive_jid,
self.unique_id,
- groupchat=True):
+ groupchat=type_ == 'groupchat'):
return
address_tag = self.stanza.getTag('addresses',
@@ -1406,6 +1437,21 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
return True
def get_unique_id(self):
+ '''
+ Messages to self:
+
+ Messages to self are stored multiple times in MAM so we cant use
+ stanza-id to deduplicate. We use origin-id instead. Its not perfect
+ but there is no better way for now.
+ We drop "received"-Carbons of Message to self, so we dont have to
+ parse origin-id in that case.
+
+ MUC PMs:
+
+ MUC PMs are also stored multiple times, we also depend on origin-id
+ for now.
+ '''
+
if self.stanza.getType() == 'groupchat':
# TODO: Disco the MUC check if 'urn:xmpp:mam:2' is announced
return self.get_stanza_id(self.stanza)
@@ -1424,6 +1470,8 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
protocol=True)
if sent_carbon is not None:
message = self.get_forwarded_message(sent_carbon)
+ if self._is_self_message(message) or self._is_muc_pm(message):
+ return message.getOriginID()
return self.get_stanza_id(message)
# Received Carbon
@@ -1432,9 +1480,13 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
protocol=True)
if received_carbon is not None:
message = self.get_forwarded_message(received_carbon)
+ if self._is_muc_pm(message):
+ return message.getOriginID()
return self.get_stanza_id(message)
# Normal Message
+ if self._is_self_message(self.stanza) or self._is_muc_pm(self.stanza):
+ return self.stanza.getOriginID()
return self.get_stanza_id(self.stanza)
class ZeroconfMessageReceivedEvent(MessageReceivedEvent):
=====================================
gajim/common/logger.py
=====================================
--- a/gajim/common/logger.py
+++ b/gajim/common/logger.py
@@ -1158,6 +1158,7 @@ class Logger:
:param account: The account
:param archive_jid: The jid of the archive the stanza-id belongs to
+ only used if groupchat=True
:param stanza_id: The stanza-id
@@ -1182,7 +1183,7 @@ class Logger:
if groupchat:
# Stanza ID is only unique within a specific archive.
# So a Stanza ID could be repeated in different MUCs, so we
- # filter also for the archive JID
+ # filter also for the archive JID which is the bare MUC jid.
sql = '''
SELECT stanza_id FROM logs
WHERE stanza_id IN ({values})
@@ -1193,14 +1194,14 @@ class Logger:
else:
sql = '''
SELECT stanza_id FROM logs
- WHERE stanza_id IN ({values}) AND account_id = ? LIMIT 1
+ WHERE stanza_id IN ({values}) AND account_id = ? AND kind != ? LIMIT 1
'''.format(values=', '.join('?' * len(ids)))
result = self.con.execute(
- sql, tuple(ids) + (account_id,)).fetchone()
+ sql, tuple(ids) + (account_id, KindConstant.GC_MSG)).fetchone()
if result is not None:
log.info('Found duplicated message, stanza-id: %s, origin-id: %s, '
- 'archive-jid: %s, account: %s', stanza_id, origin_id, archive_id, account_id)
+ 'archive-jid: %s, account: %s', stanza_id, origin_id, archive_jid, account_id)
return True
return False
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/d6bfea1b19f11183edb25a086c3faa0b1…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/d6bfea1b19f11183edb25a086c3faa0b1…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / gajim
Commits:
27ffae2a by Philipp Hörist at 2018-02-20T22:03:57+01:00
Fix MessagTextview height
On some Desktops eg. Mate, the MessageTextview was to big, because
the default height seems to be 82.
What influences the default height (compare Windows where it is 46),
is unclear.
- - - - -
d6bfea1b by Philipp Hörist at 2018-02-20T22:51:28+01:00
Add extension point for GC tooltip
- - - - -
2 changed files:
- gajim/chat_control_base.py
- gajim/tooltips.py
Changes:
=====================================
gajim/chat_control_base.py
=====================================
--- a/gajim/chat_control_base.py
+++ b/gajim/chat_control_base.py
@@ -1380,13 +1380,12 @@ class ScrolledWindow(Gtk.ScrolledWindow):
def do_get_preferred_height(self):
min_height, natural_height = Gtk.ScrolledWindow.do_get_preferred_height(self)
- child = self.get_child()
# Gtk Bug: If policy is set to Automatic, the ScrolledWindow
- # has a min size of around 46 depending on the System. Because
- # we want it smaller, we set policy NEVER if the height is < 50
+ # has a min size of around 46-82 depending on the System. Because
+ # we want it smaller, we set policy NEVER if the height is < 90
# so the ScrolledWindow will shrink to around 26 (1 line heigh).
- # Once it gets over 50 its no problem to restore the policy.
- if natural_height < 50:
+ # Once it gets over 90 its no problem to restore the policy.
+ if natural_height < 90:
GLib.idle_add(self.set_policy,
Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.NEVER)
=====================================
gajim/tooltips.py
=====================================
--- a/gajim/tooltips.py
+++ b/gajim/tooltips.py
@@ -252,6 +252,9 @@ class GCTooltip():
self.avatar.show()
self.fillelement.show()
+ app.plugin_manager.gui_extension_point(
+ 'gc_tooltip_populate', self, contact, self.tooltip_grid)
+
@staticmethod
def colorize_affiliation(affiliation):
"""
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/64d743de3ee25e9ba4686d0d368a5ba2b…
---
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/64d743de3ee25e9ba4686d0d368a5ba2b…
You're receiving this email because of your account on dev.gajim.org.