Commit cd7c43de authored by Philipp Hörist's avatar Philipp Hörist

Move should_log() into helpers module

parent 24abd478
Pipeline #5974 passed with stages
in 4 minutes and 17 seconds
......@@ -628,19 +628,6 @@ class Config:
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')
......
......@@ -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)
......@@ -24,6 +24,7 @@ from nbxmpp.util import generate_id
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 @@ class Message(BaseModule):
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 @@ class Message(BaseModule):
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:
......
......@@ -540,7 +540,7 @@ class MUC(BaseModule):
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()
......
......@@ -25,6 +25,7 @@ from gajim.common import app
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 @@ class Presence(BaseModule):
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]
......
......@@ -66,8 +66,7 @@ class ChatControlSession:
)
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()
......
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