From 4cd1448d0e16d19a1f255ed6746a7372221e84cd Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 5 Oct 2020 20:27:14 +0100 Subject: [PATCH] Fix third-party event modules for `check_visibility_can_be_modified` check PR #8292 tried to maintain backwards compat with modules which don't provide a `check_visibility_can_be_modified` method, but the tests weren't being run, and the check didn't work. --- changelog.d/8467.feature | 1 + synapse/events/third_party_rules.py | 4 +++- .../{third_party_rules.py => test_third_party_rules.py} | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/8467.feature rename tests/rest/client/{third_party_rules.py => test_third_party_rules.py} (96%) diff --git a/changelog.d/8467.feature b/changelog.d/8467.feature new file mode 100644 index 000000000..6d0335e2c --- /dev/null +++ b/changelog.d/8467.feature @@ -0,0 +1 @@ +Allow `ThirdPartyEventRules` modules to query and manipulate whether a room is in the public rooms directory. \ No newline at end of file diff --git a/synapse/events/third_party_rules.py b/synapse/events/third_party_rules.py index fed459198..1ca77519d 100644 --- a/synapse/events/third_party_rules.py +++ b/synapse/events/third_party_rules.py @@ -131,7 +131,9 @@ class ThirdPartyEventRules: if self.third_party_rules is None: return True - check_func = getattr(self.third_party_rules, "check_visibility_can_be_modified") + check_func = getattr( + self.third_party_rules, "check_visibility_can_be_modified", None + ) if not check_func or not isinstance(check_func, Callable): return True diff --git a/tests/rest/client/third_party_rules.py b/tests/rest/client/test_third_party_rules.py similarity index 96% rename from tests/rest/client/third_party_rules.py rename to tests/rest/client/test_third_party_rules.py index 715e87de0..7b322f526 100644 --- a/tests/rest/client/third_party_rules.py +++ b/tests/rest/client/test_third_party_rules.py @@ -49,7 +49,7 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase): def make_homeserver(self, reactor, clock): config = self.default_config() config["third_party_event_rules"] = { - "module": "tests.rest.client.third_party_rules.ThirdPartyRulesTestModule", + "module": __name__ + ".ThirdPartyRulesTestModule", "config": {}, }