diff --git a/gajim/common/config.py b/gajim/common/config.py index ded1ca430edf69296b13a3393383d66aafad6cae..6983528e276633c27e679c9c537a2a2b9e1e1ac2 100644 --- a/gajim/common/config.py +++ b/gajim/common/config.py @@ -628,19 +628,6 @@ def get_restart_per(self, optname, key=None, subname=None): return obj[subname][Option.RESTART] return False - def should_log(self, account, jid): - """ - Should conversations between a local account and a remote jid be logged? - """ - no_log_for = self.get_per('accounts', account, 'no_log_for') - - if not no_log_for: - no_log_for = '' - - no_log_for = no_log_for.split() - - return (account not in no_log_for) and (jid not in no_log_for) - def notify_for_muc(self, room): all_ = self.get('notify_on_all_muc_messages') room = self.get_per('rooms', room, 'notify_on_all_messages') diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index 4255e9a4c186c5cd52bca5e800a9da3a0fcb6a5a..b14c49493a3b0eb58dda3b1d6aabcb2a66419948 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -1556,3 +1556,17 @@ def get_idle_status_message(state, status_message): 'time': app.config.get(f'auto{state}time') } return message + + +def should_log(account, jid): + """ + Should conversations between a local account and a remote jid be logged? + """ + no_log_for = app.config.get_per('accounts', account, 'no_log_for') + + if not no_log_for: + no_log_for = '' + + no_log_for = no_log_for.split() + + return (account not in no_log_for) and (jid not in no_log_for) diff --git a/gajim/common/modules/message.py b/gajim/common/modules/message.py index ff3fd05a202bfe931d792a64d61f810566676a40..5fb9d6cd0afd8de410ca95e89b666247cb9f5387 100644 --- a/gajim/common/modules/message.py +++ b/gajim/common/modules/message.py @@ -24,6 +24,7 @@ from gajim.common import app from gajim.common.nec import NetworkEvent from gajim.common.helpers import AdditionalDataDict +from gajim.common.helpers import should_log from gajim.common.const import KindConstant from gajim.common.modules.base import BaseModule from gajim.common.modules.util import get_eme_message @@ -236,7 +237,7 @@ def _message_error_received(self, _con, _stanza, properties): def _log_muc_message(self, event): self._check_for_mam_compliance(event.room_jid, event.stanza_id) - if (app.config.should_log(self._account, event.jid) and + if (should_log(self._account, event.jid) and event.msgtxt and event.properties.muc_nickname): # if not event.nick, it means message comes from room itself # usually it hold description and can be send at each connection @@ -355,7 +356,7 @@ def log_message(self, message): if not message.is_loggable: return - if not app.config.should_log(self._account, message.jid): + if not should_log(self._account, message.jid): return if message.message is None: diff --git a/gajim/common/modules/muc.py b/gajim/common/modules/muc.py index c57cdd978b1b77a7917d0534e14d839b20598fbd..3a2a57f94b51551204b52c898298da870c904113 100644 --- a/gajim/common/modules/muc.py +++ b/gajim/common/modules/muc.py @@ -540,7 +540,7 @@ def _log_muc_event(self, event_name, properties): return if (not app.config.get('log_contact_status_changes') or - not app.config.should_log(self._account, properties.jid)): + not helpers.should_log(self._account, properties.jid)): return additional_data = AdditionalDataDict() diff --git a/gajim/common/modules/presence.py b/gajim/common/modules/presence.py index 0b25818f73e5e567ea2e060e4453670efc64aa44..ff50aa23edf8141d397972c562085afe8700dbbd 100644 --- a/gajim/common/modules/presence.py +++ b/gajim/common/modules/presence.py @@ -25,6 +25,7 @@ from gajim.common import idle from gajim.common.i18n import _ from gajim.common.nec import NetworkEvent +from gajim.common.helpers import should_log from gajim.common.const import KindConstant from gajim.common.const import ShowConstant from gajim.common.modules.base import BaseModule @@ -228,7 +229,7 @@ def _is_resource_known(contact_list): def _log_presence(self, properties): if not app.config.get('log_contact_status_changes'): return - if not app.config.should_log(self._account, properties.jid.getBare()): + if not should_log(self._account, properties.jid.getBare()): return show = ShowConstant[properties.show.name] diff --git a/gajim/session.py b/gajim/session.py index 50f0d8bb7938d31a39a2f98bd76e0200338d3913..f9568ad9ed5f590182913addd84c601764cb426e 100644 --- a/gajim/session.py +++ b/gajim/session.py @@ -66,8 +66,7 @@ def generate_thread_id(self): ) def is_loggable(self): - return app.config.should_log(self.conn.name, - self.jid.getStripped()) + return helpers.should_log(self.conn.name, self.jid.getStripped()) def get_to(self): bare_jid = self.jid.getBare()