Philipp Hörist pushed to branch master at gajim / gajim
Commits:
6cf22081 by Philipp Hörist at 2024-06-20T20:45:12+02:00
cfix: Setting: Add fallback address on migration
- - - - -
d0559a86 by Philipp Hörist at 2024-06-20T21:04:33+02:00
fix: Search: Don’t search messages of disabled accounts
Fixes #11876
- - - - -
2 changed files:
- gajim/common/settings.py
- gajim/common/storage/archive/storage.py
Changes:
=====================================
gajim/common/settings.py
=====================================
@@ -398,7 +398,7 @@ def _migrate(self) -> None:
address = JID.from_string(f'{localpart}@{domain}')
except Exception as error:
log.warning('Unable to migrate address: %s', error)
- continue
+ address = JID.from_string('[email protected]')
settings['address'] = str(address)
=====================================
gajim/common/storage/archive/storage.py
=====================================
@@ -110,6 +110,10 @@ def _load_jids(self, session: Session) -> None:
jids = session.scalars(select(Remote))
self._jid_pks = {j.jid: j.pk for j in jids}
+ def _get_active_account_pks(self, session: Session) -> list[int]:
+ accounts = app.settings.get_active_accounts()
+ return [self._get_account_pk(session, account) for account in accounts]
+
def _get_account_pk(self, session: Session, account: str) -> int:
pk = self._account_pks.get(account)
if pk is not None:
@@ -696,18 +700,16 @@ def search_archive(
if after is None:
after = FIRST_UTC_DATETIME
- fk_account_pk = None
- if account is not None:
- fk_account_pk = self._get_account_pk(session, account)
+ if account is None:
+ fk_account_pks = self._get_active_account_pks(session)
+ else:
+ fk_account_pks = [self._get_account_pk(session, account)]
fk_remote_pk = None
if jid is not None:
fk_remote_pk = self._get_jid_pk(session, jid)
- stmt = select(Message)
-
- if fk_account_pk is not None:
- stmt = stmt.where(Message.fk_account_pk == fk_account_pk)
+ stmt = select(Message).where(Message.fk_account_pk.in_(fk_account_pks))
if fk_remote_pk is not None:
stmt = stmt.where(Message.fk_remote_pk == fk_remote_pk)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/71b66869625d8c66831c93e4375bad9738b56fa6...d0559a86e7fd8c3a121a2d2ce052676c89efe175
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/71b66869625d8c66831c93e4375bad9738b56fa6...d0559a86e7fd8c3a121a2d2ce052676c89efe175
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]