Commit 9314a054 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Add non-compliant mam:2 MUCs to blacklist

For MUCs on the blacklist we do a deduplication not depending on

This patch is only for current Prosody 0.10 stable and the mod_mam_muc
module which does not add stanza-id to the messages.

This can be removed once Prosody 0.11 hits or the module is updated
parent 4e1a9db6
......@@ -305,6 +305,7 @@ class Config:
'use_keyring': [opt_bool, True, _('If True, Gajim will use the Systems Keyring to store account passwords.')],
'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True],
'remote_commands': [opt_bool, False, _('If True, Gajim will execute XEP-0146 Commands.')],
'mam_blacklist': [opt_str, '', _('All non-compliant MAM Groupchats')],
}, {})
__options_per_key = {
......@@ -1067,9 +1067,17 @@ def _nec_decrypted_message_received(self, obj):
conn=self, msg_obj=obj, stanza_id=obj.unique_id))
return True
def _check_for_mam_compliance(self, room_jid, stanza_id):
namespace = muc_caps_cache.get_mam_namespace(room_jid)
if stanza_id is None and namespace == nbxmpp.NS_MAM_2:
def _nec_gc_message_received(self, obj):
if !=
self._check_for_mam_compliance(obj.jid, obj.unique_id)
if (app.config.should_log(, obj.jid) and
obj.msgtxt and obj.nick):
# if not obj.nick, it means message comes from room itself
......@@ -1626,3 +1626,21 @@ def get_emoticon_theme_path(theme):
emoticons_user_path = os.path.join(app.MY_EMOTS_PATH, theme)
if os.path.exists(emoticons_user_path):
return emoticons_user_path
def add_to_mam_blacklist(jid):
config_value = app.config.get('mam_blacklist')
if not config_value:
config_value = [jid]
if jid in config_value:
config_value = config_value.split(',')
log.warning('Found not-compliant MUC. %s added to MAM Blacklist', jid)
app.config.set('mam_blacklist', ','.join(config_value))
def get_mam_blacklist():
config_value = app.config.get('mam_blacklist')
if not config_value:
return []
return config_value.split(',')
......@@ -25,6 +25,7 @@
from gajim.common import app
from gajim.common import ged
from gajim.common import helpers
from gajim.common.logger import KindConstant, JIDConstant
from gajim.common.const import ArchiveState
from gajim.common.caps_cache import muc_caps_cache
......@@ -205,7 +206,8 @@ def _nec_mam_decrypted_message_received(self, obj):
if obj.groupchat:
namespace = muc_caps_cache.get_mam_namespace(obj.room_jid)
if namespace != nbxmpp.NS_MAM_2:
blacklisted = obj.room_jid in helpers.get_mam_blacklist()
if namespace != nbxmpp.NS_MAM_2 or blacklisted:
# Fallback duplicate search without stanza-id
duplicate = app.logger.search_for_duplicate(, obj.with_, obj.timestamp, obj.msgtxt)
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