Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2023-02-27 22:27:46 +0300
committerwurstsalat <mailtrash@posteo.de>2023-06-15 22:54:42 +0300
commitd4f2f338515dca37bbc5b937ffd52800db667525 (patch)
tree3b6219cc7a58698fe4ffc7c6bbe9b0793557e72a
parent22108427be37c9e5ed91b7351d2c74c9be083333 (diff)
other: Add settings migration for workspace settingsworkspace-improvements
-rw-r--r--gajim/common/settings.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/gajim/common/settings.py b/gajim/common/settings.py
index 0cb841699..dfb6c6c4d 100644
--- a/gajim/common/settings.py
+++ b/gajim/common/settings.py
@@ -391,6 +391,61 @@ class Settings:
self._settings['app'].pop('muclumbus_api_http_uri', None)
self._set_user_version(5)
+ if version < 6:
+ # Migrate workspace chats to contact/group chat contact settings
+ for workspace_id, settings in self._settings['workspaces'].items():
+ workspace_settings = cast(
+ OpenChatsSettingT, settings.get('chats', []))
+ for chat in workspace_settings:
+ if chat['type'] in ('contact', 'pm'):
+ self.set_contact_setting(
+ chat['account'],
+ chat['jid'],
+ 'workspace',
+ workspace_id)
+ self.set_contact_setting(
+ chat['account'],
+ chat['jid'],
+ 'opened',
+ True)
+ if chat['pinned']:
+ self.set_contact_setting(
+ chat['account'],
+ chat['jid'],
+ 'pinned',
+ chat['pinned'])
+ if chat['position'] != -1:
+ self.set_contact_setting(
+ chat['account'],
+ chat['jid'],
+ 'position',
+ chat['position'])
+ elif chat['type'] == 'groupchat':
+ self.set_group_chat_setting(
+ chat['account'],
+ chat['jid'],
+ 'workspace',
+ workspace_id)
+ self.set_group_chat_setting(
+ chat['account'],
+ chat['jid'],
+ 'opened',
+ True)
+ if chat['pinned']:
+ self.set_group_chat_setting(
+ chat['account'],
+ chat['jid'],
+ 'pinned',
+ chat['pinned'])
+ if chat['position'] != -1:
+ self.set_group_chat_setting(
+ chat['account'],
+ chat['jid'],
+ 'position',
+ chat['position'])
+
+ self._set_user_version(6)
+
def _migrate_old_config(self) -> None:
if self._in_memory:
return