diff options
author | Erik Johnston <erik@matrix.org> | 2019-03-18 10:16:19 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-03-18 15:50:55 +0000 |
commit | 4eca8d3fb3d906b1bc5be6c8d4b98cf555e154b7 (patch) | |
tree | a8a511945a0aaa040dfd796a689a8465d01e9e76 /synapse/events | |
parent | Merge pull request #4862 from matrix-org/erikj/dinsic-merged-master (diff) | |
download | synapse-4eca8d3fb3d906b1bc5be6c8d4b98cf555e154b7.tar.xz |
Add invite_list and cloning param to create room rule
Diffstat (limited to 'synapse/events')
-rw-r--r-- | synapse/events/spamcheck.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/synapse/events/spamcheck.py b/synapse/events/spamcheck.py index 633e068eb8..aa559e1f50 100644 --- a/synapse/events/spamcheck.py +++ b/synapse/events/spamcheck.py @@ -46,13 +46,18 @@ class SpamChecker(object): return self.spam_checker.check_event_for_spam(event) - def user_may_invite(self, inviter_userid, invitee_userid, room_id): + def user_may_invite(self, inviter_userid, invitee_userid, room_id, new_room): """Checks if a given user may send an invite If this method returns false, the invite will be rejected. Args: - userid (string): The sender's user ID + inviter_userid (str) + invitee_userid (str) + room_id (str) + new_room (bool): Wether the user is being invited to the room as + part of a room creation, if so the invitee would have been + included in the call to `user_may_create_room`. Returns: bool: True if the user may send an invite, otherwise False @@ -60,15 +65,21 @@ class SpamChecker(object): if self.spam_checker is None: return True - return self.spam_checker.user_may_invite(inviter_userid, invitee_userid, room_id) + return self.spam_checker.user_may_invite( + inviter_userid, invitee_userid, room_id, new_room, + ) - def user_may_create_room(self, userid): + def user_may_create_room(self, userid, invite_list, cloning): """Checks if a given user may create a room If this method returns false, the creation request will be rejected. Args: userid (string): The sender's user ID + invite_list (list[str]): List of user IDs that would be invited to + the new room. + cloning (bool): Whether the user is cloning an existing room, e.g. + upgrading a room. Returns: bool: True if the user may create a room, otherwise False @@ -76,7 +87,7 @@ class SpamChecker(object): if self.spam_checker is None: return True - return self.spam_checker.user_may_create_room(userid) + return self.spam_checker.user_may_create_room(userid, invite_list, cloning) def user_may_create_room_alias(self, userid, room_alias): """Checks if a given user may create a room alias |