Add non-compliant mam:2 MUCs to blacklist
For MUCs on the blacklist we do a deduplication not depending on stanza-id 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
This commit is contained in:
parent
4e1a9db6cc
commit
9314a0543b
|
@ -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 @@ class ConnectionHandlersBase:
|
|||
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:
|
||||
helpers.add_to_mam_blacklist(room_jid)
|
||||
|
||||
def _nec_gc_message_received(self, obj):
|
||||
if obj.conn.name != self.name:
|
||||
return
|
||||
|
||||
self._check_for_mam_compliance(obj.jid, obj.unique_id)
|
||||
|
||||
if (app.config.should_log(obj.conn.name, 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]
|
||||
else:
|
||||
if jid in config_value:
|
||||
return
|
||||
config_value = config_value.split(',')
|
||||
config_value.append(jid)
|
||||
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 @@ import nbxmpp
|
|||
|
||||
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 @@ class ConnectionArchive313:
|
|||
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(
|
||||
self.name, obj.with_, obj.timestamp, obj.msgtxt)
|
||||
|
|
Loading…
Reference in New Issue