Third party event rules Update (#6781)

This commit is contained in:
PeerD 2020-02-06 15:15:29 +01:00 committed by GitHub
parent ed630ea17c
commit 99fcc96289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

1
changelog.d/6781.bugfix Normal file
View File

@ -0,0 +1 @@
Fixed third party event rules function `on_create_room`'s return value being ignored.

View File

@ -74,15 +74,16 @@ class ThirdPartyEventRules(object):
is_requester_admin (bool): If the requester is an admin
Returns:
defer.Deferred
defer.Deferred[bool]: Whether room creation is allowed or denied.
"""
if self.third_party_rules is None:
return
return True
yield self.third_party_rules.on_create_room(
ret = yield self.third_party_rules.on_create_room(
requester, config, is_requester_admin
)
return ret
@defer.inlineCallbacks
def check_threepid_can_be_invited(self, medium, address, room_id):

View File

@ -579,9 +579,13 @@ class RoomCreationHandler(BaseHandler):
# Check whether the third party rules allows/changes the room create
# request.
yield self.third_party_event_rules.on_create_room(
event_allowed = yield self.third_party_event_rules.on_create_room(
requester, config, is_requester_admin=is_requester_admin
)
if not event_allowed:
raise SynapseError(
403, "You are not permitted to create rooms", Codes.FORBIDDEN
)
if not is_requester_admin and not self.spam_checker.user_may_create_room(
user_id