Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
7cf3fbd3
by Philipp Hörist at 2022-09-05T22:37:23+02:00
-
2b123a75
by Philipp Hörist at 2022-09-05T22:42:42+02:00
5 changed files:
- gajim/common/const.py
- gajim/common/modules/muc.py
- gajim/common/modules/presence.py
- gajim/common/setting_values.py
- gajim/common/storage/archive.py
Changes:
| ... | ... | @@ -113,16 +113,6 @@ def __str__(self): |
| 113 | 113 | return str(self.value)
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | -@unique
|
|
| 117 | -class ShowConstant(IntEnum):
|
|
| 118 | - ONLINE = 0
|
|
| 119 | - CHAT = 1
|
|
| 120 | - AWAY = 2
|
|
| 121 | - XA = 3
|
|
| 122 | - DND = 4
|
|
| 123 | - OFFLINE = 5
|
|
| 124 | - |
|
| 125 | - |
|
| 126 | 116 | @unique
|
| 127 | 117 | class TypeConstant(IntEnum):
|
| 128 | 118 | AIM = 0
|
| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 | |
| 27 | 27 | import nbxmpp
|
| 28 | 28 | from nbxmpp.const import InviteType
|
| 29 | -from nbxmpp.const import PresenceType
|
|
| 30 | 29 | from nbxmpp.const import StatusCode
|
| 31 | 30 | from nbxmpp.errors import StanzaError
|
| 32 | 31 | from nbxmpp.modules.dataforms import SimpleDataForm
|
| ... | ... | @@ -48,13 +47,12 @@ |
| 48 | 47 | from gajim.common import events
|
| 49 | 48 | from gajim.common import helpers
|
| 50 | 49 | from gajim.common import types
|
| 51 | -from gajim.common.const import ClientState, KindConstant
|
|
| 50 | +from gajim.common.const import ClientState
|
|
| 52 | 51 | from gajim.common.const import MUCJoinedState
|
| 53 | 52 | from gajim.common.events import MessageModerated
|
| 54 | 53 | from gajim.common.events import MucAdded
|
| 55 | 54 | from gajim.common.events import MucDecline
|
| 56 | 55 | from gajim.common.events import MucInvitation
|
| 57 | -from gajim.common.helpers import AdditionalDataDict
|
|
| 58 | 56 | from gajim.common.helpers import get_default_muc_config
|
| 59 | 57 | from gajim.common.helpers import get_group_chat_nick
|
| 60 | 58 | from gajim.common.structs import MUCData
|
| ... | ... | @@ -814,42 +812,6 @@ def _remove_join_timeout(self, room_jid: str) -> None: |
| 814 | 812 | GLib.source_remove(id_)
|
| 815 | 813 | del self._join_timeouts[room_jid]
|
| 816 | 814 | |
| 817 | - def _log_muc_event(self,
|
|
| 818 | - event_name: str,
|
|
| 819 | - properties: PresenceProperties
|
|
| 820 | - ) -> None:
|
|
| 821 | - # TODO CURRENTLY NOT USED
|
|
| 822 | - if event_name not in ['muc-user-joined',
|
|
| 823 | - 'muc-user-left',
|
|
| 824 | - 'muc-user-status-show-changed']:
|
|
| 825 | - return
|
|
| 826 | - |
|
| 827 | - if not app.settings.get('log_contact_status_changes'):
|
|
| 828 | - return
|
|
| 829 | - |
|
| 830 | - additional_data = AdditionalDataDict()
|
|
| 831 | - if properties.muc_user is not None:
|
|
| 832 | - if properties.muc_user.jid is not None:
|
|
| 833 | - additional_data.set_value(
|
|
| 834 | - 'gajim', 'real_jid', str(properties.muc_user.jid))
|
|
| 835 | - |
|
| 836 | - # TODO: Refactor
|
|
| 837 | - if properties.type == PresenceType.UNAVAILABLE:
|
|
| 838 | - show = 'offline'
|
|
| 839 | - else:
|
|
| 840 | - show = properties.show.value
|
|
| 841 | - show = app.storage.archive.convert_show_values_to_db_api_values(show)
|
|
| 842 | - |
|
| 843 | - app.storage.archive.insert_into_logs(
|
|
| 844 | - self._account,
|
|
| 845 | - properties.jid.bare,
|
|
| 846 | - properties.timestamp,
|
|
| 847 | - KindConstant.GCSTATUS,
|
|
| 848 | - contact_name=properties.muc_nickname,
|
|
| 849 | - message=properties.status or None,
|
|
| 850 | - show=show,
|
|
| 851 | - additional_data=additional_data)
|
|
| 852 | - |
|
| 853 | 815 | def _on_subject_change(self,
|
| 854 | 816 | _con: types.xmppClient,
|
| 855 | 817 | _stanza: Message,
|
| ... | ... | @@ -38,8 +38,6 @@ |
| 38 | 38 | from gajim.common.events import UnsubscribedPresenceReceived
|
| 39 | 39 | from gajim.common.i18n import _
|
| 40 | 40 | from gajim.common.structs import PresenceData
|
| 41 | -from gajim.common.const import KindConstant
|
|
| 42 | -from gajim.common.const import ShowConstant
|
|
| 43 | 41 | from gajim.common.modules.base import BaseModule
|
| 44 | 42 | |
| 45 | 43 | |
| ... | ... | @@ -156,23 +154,6 @@ def _presence_received(self, |
| 156 | 154 | |
| 157 | 155 | app.ged.raise_event(PresenceReceived(**event_attrs))
|
| 158 | 156 | |
| 159 | - self._log_presence(properties)
|
|
| 160 | - |
|
| 161 | - def _log_presence(self, properties: PresenceProperties) -> None:
|
|
| 162 | - if not app.settings.get('log_contact_status_changes'):
|
|
| 163 | - return
|
|
| 164 | - |
|
| 165 | - show = ShowConstant[properties.show.name]
|
|
| 166 | - if properties.type.is_unavailable:
|
|
| 167 | - show = ShowConstant.OFFLINE
|
|
| 168 | - |
|
| 169 | - app.storage.archive.insert_into_logs(self._account,
|
|
| 170 | - properties.jid.bare,
|
|
| 171 | - time.time(),
|
|
| 172 | - KindConstant.STATUS,
|
|
| 173 | - message=properties.status,
|
|
| 174 | - show=show)
|
|
| 175 | - |
|
| 176 | 157 | def _subscribe_received(self,
|
| 177 | 158 | _con: types.xmppClient,
|
| 178 | 159 | _stanza: nbxmpp.protocol.Presence,
|
| ... | ... | @@ -63,7 +63,6 @@ class _ACCOUNT_DEFAULT: |
| 63 | 63 | 'hide_groupchat_occupants_list',
|
| 64 | 64 | 'ignore_incoming_attention',
|
| 65 | 65 | 'is_window_visible',
|
| 66 | - 'log_contact_status_changes',
|
|
| 67 | 66 | 'muc_prefer_direct_msg',
|
| 68 | 67 | 'notification_preview_message',
|
| 69 | 68 | 'notify_on_all_muc_messages',
|
| ... | ... | @@ -221,7 +220,6 @@ class _ACCOUNT_DEFAULT: |
| 221 | 220 | 'last_sounds_dir': '',
|
| 222 | 221 | 'last_update_check': '',
|
| 223 | 222 | 'latest_disco_addresses': '',
|
| 224 | - 'log_contact_status_changes': False,
|
|
| 225 | 223 | 'mainwin_height': 500,
|
| 226 | 224 | 'mainwin_width': 1000,
|
| 227 | 225 | 'mainwin_x_position': 0,
|
| ... | ... | @@ -676,12 +674,9 @@ class WorkspaceSettings(TypedDict): |
| 676 | 674 | 'groupchat_roster_width': _('Width of group chat roster in pixel'),
|
| 677 | 675 | 'hide_chat_banner': _('Hides the banner in a 1:1 chat window.'),
|
| 678 | 676 | 'hide_groupchat_banner': _('Hides the banner in a group chat window.'),
|
| 679 | - 'hide_groupchat_occupants_list': _(
|
|
| 680 | - 'Hides the group chat participants list in a group chat window.'),
|
|
| 681 | 677 | 'ignore_incoming_attention': _(
|
| 682 | 678 | 'If enabled, Gajim will ignore incoming attention '
|
| 683 | 679 | 'requests ("wizz").'),
|
| 684 | - 'log_contact_status_changes': '',
|
|
| 685 | 680 | 'muc_highlight_words': _(
|
| 686 | 681 | 'A list of words (semicolon separated) that will be '
|
| 687 | 682 | 'highlighted in group chats.'),
|
| ... | ... | @@ -43,7 +43,6 @@ |
| 43 | 43 | from gajim.common import configpaths
|
| 44 | 44 | from gajim.common.helpers import AdditionalDataDict
|
| 45 | 45 | from gajim.common.const import MAX_MESSAGE_CORRECTION_DELAY
|
| 46 | -from gajim.common.const import ShowConstant
|
|
| 47 | 46 | from gajim.common.const import KindConstant
|
| 48 | 47 | from gajim.common.const import JIDConstant
|
| 49 | 48 | |
| ... | ... | @@ -340,31 +339,6 @@ def get_jid_id(self, |
| 340 | 339 | self._delayed_commit()
|
| 341 | 340 | return lastrowid
|
| 342 | 341 | |
| 343 | - @staticmethod
|
|
| 344 | - def convert_show_values_to_db_api_values(show: Optional[str]
|
|
| 345 | - ) -> Optional[ShowConstant]:
|
|
| 346 | - '''
|
|
| 347 | - Convert from string style to constant ints for db
|
|
| 348 | - '''
|
|
| 349 | - |
|
| 350 | - if show == 'online':
|
|
| 351 | - return ShowConstant.ONLINE
|
|
| 352 | - if show == 'chat':
|
|
| 353 | - return ShowConstant.CHAT
|
|
| 354 | - if show == 'away':
|
|
| 355 | - return ShowConstant.AWAY
|
|
| 356 | - if show == 'xa':
|
|
| 357 | - return ShowConstant.XA
|
|
| 358 | - if show == 'dnd':
|
|
| 359 | - return ShowConstant.DND
|
|
| 360 | - if show == 'offline':
|
|
| 361 | - return ShowConstant.OFFLINE
|
|
| 362 | - if show is None:
|
|
| 363 | - return ShowConstant.ONLINE
|
|
| 364 | - # invisible in GC when someone goes invisible
|
|
| 365 | - # it's a RFC violation .... but we should not crash
|
|
| 366 | - return None
|
|
| 367 | - |
|
| 368 | 342 | @timeit
|
| 369 | 343 | def get_conversation_before_after(self,
|
| 370 | 344 | account: str,
|