diff options
author | Philipp Hörist <philipp@hoerist.com> | 2023-11-06 12:50:43 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2023-11-06 12:50:43 +0300 |
commit | 60c44b23e769dab115e6be1740af00b43b5323d9 (patch) | |
tree | 94486e795f83a92d86a52f097c1741dda69c2846 | |
parent | 3bdddf4f172f7f026526cad18dbec082bef5ebb7 (diff) |
new: Settings: Add method for checking if account exists
-rw-r--r-- | gajim/common/settings.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gajim/common/settings.py b/gajim/common/settings.py index 063860184..105869e28 100644 --- a/gajim/common/settings.py +++ b/gajim/common/settings.py @@ -754,6 +754,9 @@ class Settings: def add_account(self, account: str) -> None: log.info('Add account: %s', account) + if account in self._account_settings: + raise ValueError('Account %s exists already' % account) + self._account_settings[account] = {'account': {}, 'contact': {}, 'group_chat': {}} @@ -775,6 +778,14 @@ class Settings: def get_accounts(self) -> list[str]: return list(self._account_settings.keys()) + def account_exists(self, jid: str) -> bool: + for account in self._account_settings: + name = self.get_account_setting(account, 'name') + hostname = self.get_account_setting(account, 'hostname') + if jid == f'{name}@{hostname}': + return True + return False + def get_active_accounts(self) -> list[str]: active: list[str] = [] for account in self._account_settings: |