This repository was archived by the owner on Mar 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
synapse/storage/databases/main Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 5555logger = 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
6162class 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
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments