Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit 431eed9

Browse files
committed
Disallow ignoring hungryserv bridge bots as well
1 parent c162554 commit 431eed9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

synapse/storage/databases/main/account_data.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
logger = logging.getLogger(__name__)
5656

5757
# Regex pattern for detecting a bridge bot (cached here for performance)
58-
BOT_PATTERN = re.compile(r"^@_.*_bot\:.*")
58+
SYNAPSE_BOT_PATTERN = re.compile(r"^@_.*_bot\:*")
59+
HUNGRYSERV_BOT_PATTERN = re.compile(r"^@[a-z]+bot\:beeper.local")
5960

6061

6162
class AccountDataWorkerStore(PushRulesWorkerStore, CacheInvalidationWorkerStore):
@@ -619,7 +620,11 @@ def _add_account_data_for_user(
619620
ignored_users = content.get("ignored_users", {})
620621
if isinstance(ignored_users, dict):
621622
content["ignored_users"] = {
622-
u: v for u, v in ignored_users.items() if not BOT_PATTERN.match(u)
623+
u: v
624+
for u, v in ignored_users.items()
625+
if not (
626+
SYNAPSE_BOT_PATTERN.match(u) or HUNGRYSERV_BOT_PATTERN.match(u)
627+
)
623628
}
624629

625630
# no need to lock here as account_data has a unique constraint on

tests/storage/test_account_data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ def test_ignoring_bot_users(self) -> None:
9393
self._update_ignore_list("@other:test", "@another:remote", "@_other_bot:test")
9494
self.assert_ignored(self.user, {"@other:test", "@another:remote"})
9595

96-
self._update_ignore_list("@_other_bot:test")
96+
self._update_ignore_list("@iamnotabot:beeper.com")
97+
self.assert_ignored(self.user, {"@iamnotabot:beeper.com"})
98+
99+
self._update_ignore_list("@_other_bot:beeper.com")
100+
self.assert_ignored(self.user, set())
101+
102+
self._update_ignore_list("@whatsappbot:beeper.local")
97103
self.assert_ignored(self.user, set())
98104

99105
def test_caching(self) -> None:

0 commit comments

Comments
 (0)