Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
df30c37e
by lovetox at 2022-05-22T14:31:57+02:00
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:
| ... | ... | @@ -1395,20 +1395,6 @@ def get_idle_status_message(state: str, status_message: str) -> str: |
| 1395 | 1395 | return message
|
| 1396 | 1396 | |
| 1397 | 1397 | |
| 1398 | -def should_log(account: str, jid: str) -> bool:
|
|
| 1399 | - """
|
|
| 1400 | - Should conversations between a local account and a remote jid be logged?
|
|
| 1401 | - """
|
|
| 1402 | - no_log_for = app.settings.get_account_setting(account, 'no_log_for')
|
|
| 1403 | - |
|
| 1404 | - if not no_log_for:
|
|
| 1405 | - no_log_for = ''
|
|
| 1406 | - |
|
| 1407 | - no_log_for = no_log_for.split()
|
|
| 1408 | - |
|
| 1409 | - return (account not in no_log_for) and (jid not in no_log_for)
|
|
| 1410 | - |
|
| 1411 | - |
|
| 1412 | 1398 | def ask_for_status_message(status: str, signin: bool = False) -> bool:
|
| 1413 | 1399 | if status is None:
|
| 1414 | 1400 | # We try to change the message
|
| ... | ... | @@ -28,7 +28,6 @@ |
| 28 | 28 | from gajim.common.events import MessageUpdated
|
| 29 | 29 | from gajim.common.events import RawMessageReceived
|
| 30 | 30 | from gajim.common.helpers import AdditionalDataDict
|
| 31 | -from gajim.common.helpers import should_log
|
|
| 32 | 31 | from gajim.common.const import KindConstant
|
| 33 | 32 | from gajim.common.modules.base import BaseModule
|
| 34 | 33 | from gajim.common.modules.util import get_eme_message
|
| ... | ... | @@ -200,13 +199,12 @@ def _message_received(self, _con, stanza, properties): |
| 200 | 199 | properties=properties,
|
| 201 | 200 | correct_id=correct_id)
|
| 202 | 201 | |
| 203 | - if should_log(self._account, jid):
|
|
| 204 | - app.storage.archive.store_message_correction(
|
|
| 205 | - self._account,
|
|
| 206 | - jid,
|
|
| 207 | - correct_id,
|
|
| 208 | - msgtxt,
|
|
| 209 | - properties.type.is_groupchat)
|
|
| 202 | + app.storage.archive.store_message_correction(
|
|
| 203 | + self._account,
|
|
| 204 | + jid,
|
|
| 205 | + correct_id,
|
|
| 206 | + msgtxt,
|
|
| 207 | + properties.type.is_groupchat)
|
|
| 210 | 208 | app.ged.raise_event(event)
|
| 211 | 209 | return
|
| 212 | 210 | |
| ... | ... | @@ -229,7 +227,7 @@ def _message_received(self, _con, stanza, properties): |
| 229 | 227 | if properties.is_sent_carbon:
|
| 230 | 228 | log_type = KindConstant.CHAT_MSG_SENT
|
| 231 | 229 | |
| 232 | - if not should_log(self._account, jid) or not msgtxt:
|
|
| 230 | + if not msgtxt:
|
|
| 233 | 231 | return
|
| 234 | 232 | |
| 235 | 233 | app.storage.archive.insert_into_logs(
|
| ... | ... | @@ -266,11 +264,7 @@ def _message_error_received(self, _con, _stanza, properties): |
| 266 | 264 | def _log_muc_message(self, event):
|
| 267 | 265 | self._check_for_mam_compliance(event.room_jid, event.stanza_id)
|
| 268 | 266 | |
| 269 | - if (should_log(self._account, event.jid) and
|
|
| 270 | - event.msgtxt and event.properties.muc_nickname):
|
|
| 271 | - # if not event.nick, it means message comes from room itself
|
|
| 272 | - # usually it hold description and can be send at each connection
|
|
| 273 | - # so don't store it in logs
|
|
| 267 | + if event.msgtxt and event.properties.muc_nickname:
|
|
| 274 | 268 | app.storage.archive.insert_into_logs(
|
| 275 | 269 | self._account,
|
| 276 | 270 | event.jid,
|
| ... | ... | @@ -394,9 +388,6 @@ def log_message(self, message): |
| 394 | 388 | if not message.is_loggable:
|
| 395 | 389 | return
|
| 396 | 390 | |
| 397 | - if not should_log(self._account, message.jid):
|
|
| 398 | - return
|
|
| 399 | - |
|
| 400 | 391 | if message.message is None:
|
| 401 | 392 | return
|
| 402 | 393 |
| ... | ... | @@ -620,8 +620,7 @@ def _log_muc_event(self, event_name, properties): |
| 620 | 620 | 'muc-user-status-show-changed']:
|
| 621 | 621 | return
|
| 622 | 622 | |
| 623 | - if (not app.settings.get('log_contact_status_changes') or
|
|
| 624 | - not helpers.should_log(self._account, properties.jid)):
|
|
| 623 | + if not app.settings.get('log_contact_status_changes'):
|
|
| 625 | 624 | return
|
| 626 | 625 | |
| 627 | 626 | additional_data = AdditionalDataDict()
|
| ... | ... | @@ -29,7 +29,6 @@ |
| 29 | 29 | from gajim.common.events import SubscribedPresenceReceived
|
| 30 | 30 | from gajim.common.events import UnsubscribedPresenceReceived
|
| 31 | 31 | from gajim.common.i18n import _
|
| 32 | -from gajim.common.helpers import should_log
|
|
| 33 | 32 | from gajim.common.structs import PresenceData
|
| 34 | 33 | from gajim.common.const import KindConstant
|
| 35 | 34 | from gajim.common.const import ShowConstant
|
| ... | ... | @@ -148,8 +147,6 @@ def _presence_received(self, _con, stanza, properties): |
| 148 | 147 | def _log_presence(self, properties):
|
| 149 | 148 | if not app.settings.get('log_contact_status_changes'):
|
| 150 | 149 | return
|
| 151 | - if not should_log(self._account, properties.jid.bare):
|
|
| 152 | - return
|
|
| 153 | 150 | |
| 154 | 151 | show = ShowConstant[properties.show.name]
|
| 155 | 152 | if properties.type.is_unavailable:
|
| ... | ... | @@ -353,7 +353,6 @@ class _ACCOUNT_DEFAULT: |
| 353 | 353 | 'last_status',
|
| 354 | 354 | 'last_status_msg',
|
| 355 | 355 | 'name',
|
| 356 | - 'no_log_for',
|
|
| 357 | 356 | 'password',
|
| 358 | 357 | 'proxy',
|
| 359 | 358 | 'recent_groupchats',
|
| ... | ... | @@ -442,7 +441,6 @@ class _ACCOUNT_DEFAULT: |
| 442 | 441 | 'custom_host': '',
|
| 443 | 442 | 'custom_type': 'START TLS',
|
| 444 | 443 | 'sync_with_global_status': False,
|
| 445 | - 'no_log_for': '',
|
|
| 446 | 444 | 'attached_gpg_keys': '',
|
| 447 | 445 | 'http_auth': 'ask',
|
| 448 | 446 | 'file_transfer_proxies': '',
|
| ... | ... | @@ -674,11 +674,6 @@ def __init__(self, account: str) -> None: |
| 674 | 674 | Setting(SettingKind.SWITCH, _('Connect on startup'),
|
| 675 | 675 | SettingType.ACCOUNT_CONFIG, 'autoconnect'),
|
| 676 | 676 | |
| 677 | - Setting(SettingKind.SWITCH,
|
|
| 678 | - _('Save conversations for all contacts'),
|
|
| 679 | - SettingType.ACCOUNT_CONFIG, 'no_log_for',
|
|
| 680 | - desc=_('Store conversations on the harddrive')),
|
|
| 681 | - |
|
| 682 | 677 | Setting(SettingKind.SWITCH, _('Global Status'),
|
| 683 | 678 | SettingType.ACCOUNT_CONFIG, 'sync_with_global_status',
|
| 684 | 679 | desc=_('Synchronise the status of all accounts')),
|
| ... | ... | @@ -29,7 +29,6 @@ |
| 29 | 29 | from typing import Type
|
| 30 | 30 | from typing import Optional
|
| 31 | 31 | |
| 32 | -import time
|
|
| 33 | 32 | import logging
|
| 34 | 33 | import sys
|
| 35 | 34 | |
| ... | ... | @@ -61,8 +60,6 @@ |
| 61 | 60 | from gajim.gui.conversation.view import ConversationView
|
| 62 | 61 | from gajim.gui.const import TARGET_TYPE_URI_LIST
|
| 63 | 62 | from gajim.gui.const import ControlType
|
| 64 | -from gajim.gui.dialogs import DialogButton
|
|
| 65 | -from gajim.gui.dialogs import ConfirmationDialog
|
|
| 66 | 63 | from gajim.gui.util import open_window
|
| 67 | 64 | |
| 68 | 65 | from gajim.command_system.implementation.hosts import ChatCommands
|
| ... | ... | @@ -602,36 +599,6 @@ def shutdown(self) -> None: |
| 602 | 599 | app.check_finalize(self)
|
| 603 | 600 | |
| 604 | 601 | def allow_shutdown(self, _method, on_yes, on_no):
|
| 605 | - row = self.conversation_view.get_last_message_row()
|
|
| 606 | - if row is None:
|
|
| 607 | - on_yes(self)
|
|
| 608 | - return
|
|
| 609 | - |
|
| 610 | - if time.time() - row.timestamp < 2:
|
|
| 611 | - # Under 2 seconds since last message
|
|
| 612 | - no_log_for = app.settings.get_account_setting(
|
|
| 613 | - self.account, 'no_log_for').split()
|
|
| 614 | - more = ''
|
|
| 615 | - if self.contact.jid in no_log_for:
|
|
| 616 | - more = _('Note: Chat history is disabled for this contact.')
|
|
| 617 | - if self.account in no_log_for:
|
|
| 618 | - more = _('Note: Chat history is disabled for this account.')
|
|
| 619 | - text = _('You just received a new message from %s.\n'
|
|
| 620 | - 'Do you want to close this tab?') % self.contact.name
|
|
| 621 | - if more:
|
|
| 622 | - text += '\n' + more
|
|
| 623 | - |
|
| 624 | - ConfirmationDialog(
|
|
| 625 | - _('Close'),
|
|
| 626 | - _('New Message'),
|
|
| 627 | - text,
|
|
| 628 | - [DialogButton.make('Cancel',
|
|
| 629 | - callback=lambda: on_no(self)),
|
|
| 630 | - DialogButton.make('Remove',
|
|
| 631 | - text=_('_Close'),
|
|
| 632 | - callback=lambda: on_yes(self))],
|
|
| 633 | - transient_for=app.window).show()
|
|
| 634 | - return
|
|
| 635 | 602 | on_yes(self)
|
| 636 | 603 | |
| 637 | 604 | def _on_avatar_update(self,
|
| ... | ... | @@ -326,10 +326,6 @@ def __get_value(type_: SettingType, |
| 326 | 326 | if type_ == SettingType.ACCOUNT_CONFIG:
|
| 327 | 327 | if value == 'password':
|
| 328 | 328 | return passwords.get_password(account)
|
| 329 | - if value == 'no_log_for':
|
|
| 330 | - no_log = app.settings.get_account_setting(
|
|
| 331 | - account, 'no_log_for').split()
|
|
| 332 | - return account not in no_log
|
|
| 333 | 329 | return app.settings.get_account_setting(account, value)
|
| 334 | 330 | |
| 335 | 331 | if type_ == SettingType.ACTION:
|
| ... | ... | @@ -348,9 +344,6 @@ def set_value(self, state: AllSettingsT) -> None: |
| 348 | 344 | if self.value == 'password':
|
| 349 | 345 | assert isinstance(state, str)
|
| 350 | 346 | passwords.save_password(self.account, state)
|
| 351 | - if self.value == 'no_log_for':
|
|
| 352 | - assert isinstance(state, bool)
|
|
| 353 | - self.set_no_log_for(self.account, state)
|
|
| 354 | 347 | else:
|
| 355 | 348 | app.settings.set_account_setting(self.account,
|
| 356 | 349 | self.value,
|
| ... | ... | @@ -367,17 +360,6 @@ def set_value(self, state: AllSettingsT) -> None: |
| 367 | 360 | if self.callback is not None:
|
| 368 | 361 | self.callback(state, self.data)
|
| 369 | 362 | |
| 370 | - @staticmethod
|
|
| 371 | - def set_no_log_for(account: str, state: bool) -> None:
|
|
| 372 | - no_log = app.settings.get_account_setting(account, 'no_log_for').split()
|
|
| 373 | - if state and account in no_log:
|
|
| 374 | - no_log.remove(account)
|
|
| 375 | - elif not state and account not in no_log:
|
|
| 376 | - no_log.append(account)
|
|
| 377 | - app.settings.set_account_setting(account,
|
|
| 378 | - 'no_log_for',
|
|
| 379 | - ' '.join(no_log))
|
|
| 380 | - |
|
| 381 | 363 | def on_row_activated(self) -> None:
|
| 382 | 364 | raise NotImplementedError
|
| 383 | 365 |