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

Commit 726f13e

Browse files
committed
Delete custom user_may_create_room
Because we already do these checks with RoomAccessRules
1 parent 58d6cdd commit 726f13e

File tree

2 files changed

+1
-57
lines changed

2 files changed

+1
-57
lines changed

synapse/rulecheck/domain_rule_checker.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
import logging
17-
from typing import Dict, Optional
17+
from typing import Optional
1818

1919
from synapse.api.constants import EventTypes, Membership
2020
from synapse.config._base import ConfigError
@@ -84,7 +84,6 @@ def __init__(self, config, api: ModuleApi):
8484
self._api.register_spam_checker_callbacks(
8585
user_may_invite=self.user_may_invite,
8686
user_may_send_3pid_invite=self.user_may_send_3pid_invite,
87-
user_may_create_room=self.user_may_create_room,
8887
user_may_join_room=self.user_may_join_room,
8988
)
9089

@@ -198,24 +197,6 @@ async def _user_may_invite(
198197

199198
return invitee_domain in self.domain_mapping[inviter_domain]
200199

201-
async def user_may_create_room(
202-
self, userid, invite_list, third_party_invite_list, cloning
203-
):
204-
"""Implements synapse.events.SpamChecker.user_may_create_room"""
205-
206-
if cloning:
207-
return True
208-
209-
if not self.can_invite_by_third_party_id and third_party_invite_list:
210-
return False
211-
212-
number_of_invites = len(invite_list) + len(third_party_invite_list)
213-
214-
if self.can_only_create_one_to_one_rooms and number_of_invites != 1:
215-
return False
216-
217-
return True
218-
219200
async def user_may_join_room(self, userid, room_id, is_invited):
220201
"""Implements the user_may_join_room spam checker callback."""
221202
if self.can_only_join_rooms_with_invite and not is_invited:

tests/rulecheck/test_domainrulecheck.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -272,43 +272,6 @@ def test_admin_can_create_room(self):
272272
channel = self._create_room(self.admin_access_token)
273273
assert channel.result["code"] == b"200", channel.result
274274

275-
def test_normal_user_cannot_create_empty_room(self):
276-
channel = self._create_room(self.normal_access_token)
277-
assert channel.result["code"] == b"403", channel.result
278-
279-
def test_normal_user_cannot_create_room_with_multiple_invites(self):
280-
channel = self._create_room(
281-
self.normal_access_token,
282-
content={"invite": [self.other_user_id, self.admin_user_id]},
283-
)
284-
assert channel.result["code"] == b"403", channel.result
285-
286-
# Test that it correctly counts both normal and third party invites
287-
channel = self._create_room(
288-
self.normal_access_token,
289-
content={
290-
"invite": [self.other_user_id],
291-
"invite_3pid": [{"medium": "email", "address": "[email protected]"}],
292-
},
293-
)
294-
assert channel.result["code"] == b"403", channel.result
295-
296-
# Test that it correctly rejects third party invites
297-
channel = self._create_room(
298-
self.normal_access_token,
299-
content={
300-
"invite": [],
301-
"invite_3pid": [{"medium": "email", "address": "[email protected]"}],
302-
},
303-
)
304-
assert channel.result["code"] == b"403", channel.result
305-
306-
def test_normal_user_can_room_with_single_invites(self):
307-
channel = self._create_room(
308-
self.normal_access_token, content={"invite": [self.other_user_id]}
309-
)
310-
assert channel.result["code"] == b"200", channel.result
311-
312275
def test_cannot_join_public_room(self):
313276
channel = self._create_room(self.admin_access_token)
314277
assert channel.result["code"] == b"200", channel.result

0 commit comments

Comments
 (0)