Philipp Hörist pushed to branch master at gajim / gajim
Commits: df30c37e by lovetox at 2022-05-22T14:31:57+02:00 fix: Remove `Save conversation` setting
This setting is superseded by the `Keep Chat History` setting.
- - - - -
8 changed files:
- gajim/common/helpers.py - gajim/common/modules/message.py - gajim/common/modules/muc.py - gajim/common/modules/presence.py - gajim/common/setting_values.py - gajim/gtk/accounts.py - gajim/gtk/controls/chat.py - gajim/gtk/settings.py
Changes:
===================================== gajim/common/helpers.py ===================================== @@ -1395,20 +1395,6 @@ def get_idle_status_message(state: str, status_message: str) -> str: return message
-def should_log(account: str, jid: str) -> bool: - """ - Should conversations between a local account and a remote jid be logged? - """ - no_log_for = app.settings.get_account_setting(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 ask_for_status_message(status: str, signin: bool = False) -> bool: if status is None: # We try to change the message
===================================== gajim/common/modules/message.py ===================================== @@ -28,7 +28,6 @@ from gajim.common.events import MessageUpdated from gajim.common.events import RawMessageReceived 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 @@ -200,13 +199,12 @@ def _message_received(self, _con, stanza, properties): properties=properties, correct_id=correct_id)
- if should_log(self._account, jid): - app.storage.archive.store_message_correction( - self._account, - jid, - correct_id, - msgtxt, - properties.type.is_groupchat) + app.storage.archive.store_message_correction( + self._account, + jid, + correct_id, + msgtxt, + properties.type.is_groupchat) app.ged.raise_event(event) return
@@ -229,7 +227,7 @@ def _message_received(self, _con, stanza, properties): if properties.is_sent_carbon: log_type = KindConstant.CHAT_MSG_SENT
- if not should_log(self._account, jid) or not msgtxt: + if not msgtxt: return
app.storage.archive.insert_into_logs( @@ -266,11 +264,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 (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 - # so don't store it in logs + if event.msgtxt and event.properties.muc_nickname: app.storage.archive.insert_into_logs( self._account, event.jid, @@ -394,9 +388,6 @@ def log_message(self, message): if not message.is_loggable: return
- if not should_log(self._account, message.jid): - return - if message.message is None: return
===================================== gajim/common/modules/muc.py ===================================== @@ -620,8 +620,7 @@ def _log_muc_event(self, event_name, properties): 'muc-user-status-show-changed']: return
- if (not app.settings.get('log_contact_status_changes') or - not helpers.should_log(self._account, properties.jid)): + if not app.settings.get('log_contact_status_changes'): return
additional_data = AdditionalDataDict()
===================================== gajim/common/modules/presence.py ===================================== @@ -29,7 +29,6 @@ from gajim.common.events import SubscribedPresenceReceived from gajim.common.events import UnsubscribedPresenceReceived from gajim.common.i18n import _ -from gajim.common.helpers import should_log from gajim.common.structs import PresenceData from gajim.common.const import KindConstant from gajim.common.const import ShowConstant @@ -148,8 +147,6 @@ def _presence_received(self, _con, stanza, properties): def _log_presence(self, properties): if not app.settings.get('log_contact_status_changes'): return - if not should_log(self._account, properties.jid.bare): - return
show = ShowConstant[properties.show.name] if properties.type.is_unavailable:
===================================== gajim/common/setting_values.py ===================================== @@ -353,7 +353,6 @@ class _ACCOUNT_DEFAULT: 'last_status', 'last_status_msg', 'name', - 'no_log_for', 'password', 'proxy', 'recent_groupchats', @@ -442,7 +441,6 @@ class _ACCOUNT_DEFAULT: 'custom_host': '', 'custom_type': 'START TLS', 'sync_with_global_status': False, - 'no_log_for': '', 'attached_gpg_keys': '', 'http_auth': 'ask', 'file_transfer_proxies': '',
===================================== gajim/gtk/accounts.py ===================================== @@ -674,11 +674,6 @@ def __init__(self, account: str) -> None: Setting(SettingKind.SWITCH, _('Connect on startup'), SettingType.ACCOUNT_CONFIG, 'autoconnect'),
- Setting(SettingKind.SWITCH, - _('Save conversations for all contacts'), - SettingType.ACCOUNT_CONFIG, 'no_log_for', - desc=_('Store conversations on the harddrive')), - Setting(SettingKind.SWITCH, _('Global Status'), SettingType.ACCOUNT_CONFIG, 'sync_with_global_status', desc=_('Synchronise the status of all accounts')),
===================================== gajim/gtk/controls/chat.py ===================================== @@ -29,7 +29,6 @@ from typing import Type from typing import Optional
-import time import logging import sys
@@ -61,8 +60,6 @@ from gajim.gui.conversation.view import ConversationView from gajim.gui.const import TARGET_TYPE_URI_LIST from gajim.gui.const import ControlType -from gajim.gui.dialogs import DialogButton -from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.util import open_window
from gajim.command_system.implementation.hosts import ChatCommands @@ -602,36 +599,6 @@ def shutdown(self) -> None: app.check_finalize(self)
def allow_shutdown(self, _method, on_yes, on_no): - row = self.conversation_view.get_last_message_row() - if row is None: - on_yes(self) - return - - if time.time() - row.timestamp < 2: - # Under 2 seconds since last message - no_log_for = app.settings.get_account_setting( - self.account, 'no_log_for').split() - more = '' - if self.contact.jid in no_log_for: - more = _('Note: Chat history is disabled for this contact.') - if self.account in no_log_for: - more = _('Note: Chat history is disabled for this account.') - text = _('You just received a new message from %s.\n' - 'Do you want to close this tab?') % self.contact.name - if more: - text += '\n' + more - - ConfirmationDialog( - _('Close'), - _('New Message'), - text, - [DialogButton.make('Cancel', - callback=lambda: on_no(self)), - DialogButton.make('Remove', - text=_('_Close'), - callback=lambda: on_yes(self))], - transient_for=app.window).show() - return on_yes(self)
def _on_avatar_update(self,
===================================== gajim/gtk/settings.py ===================================== @@ -326,10 +326,6 @@ def __get_value(type_: SettingType, if type_ == SettingType.ACCOUNT_CONFIG: if value == 'password': return passwords.get_password(account) - if value == 'no_log_for': - no_log = app.settings.get_account_setting( - account, 'no_log_for').split() - return account not in no_log return app.settings.get_account_setting(account, value)
if type_ == SettingType.ACTION: @@ -348,9 +344,6 @@ def set_value(self, state: AllSettingsT) -> None: if self.value == 'password': assert isinstance(state, str) passwords.save_password(self.account, state) - if self.value == 'no_log_for': - assert isinstance(state, bool) - self.set_no_log_for(self.account, state) else: app.settings.set_account_setting(self.account, self.value, @@ -367,17 +360,6 @@ def set_value(self, state: AllSettingsT) -> None: if self.callback is not None: self.callback(state, self.data)
- @staticmethod - def set_no_log_for(account: str, state: bool) -> None: - no_log = app.settings.get_account_setting(account, 'no_log_for').split() - if state and account in no_log: - no_log.remove(account) - elif not state and account not in no_log: - no_log.append(account) - app.settings.set_account_setting(account, - 'no_log_for', - ' '.join(no_log)) - def on_row_activated(self) -> None: raise NotImplementedError
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/df30c37e5627f1a0bcf6413c0c2f9ec5e...