|
26 | 26 | GuestAccess,
|
27 | 27 | Membership,
|
28 | 28 | )
|
29 |
| -from synapse.api.errors import ( |
30 |
| - AuthError, |
31 |
| - Codes, |
32 |
| - LimitExceededError, |
33 |
| - ShadowBanError, |
34 |
| - SynapseError, |
35 |
| -) |
| 29 | +from synapse.api.errors import AuthError, Codes, ShadowBanError, SynapseError |
36 | 30 | from synapse.api.ratelimiting import Ratelimiter
|
37 | 31 | from synapse.event_auth import get_named_level, get_power_level_event
|
38 | 32 | from synapse.events import EventBase
|
@@ -380,16 +374,7 @@ async def _local_membership_update(
|
380 | 374 | # Only rate-limit if the user actually joined the room, otherwise we'll end
|
381 | 375 | # up blocking profile updates.
|
382 | 376 | if newly_joined and ratelimit:
|
383 |
| - time_now_s = self.clock.time() |
384 |
| - ( |
385 |
| - allowed, |
386 |
| - time_allowed, |
387 |
| - ) = await self._join_rate_limiter_local.can_do_action(requester) |
388 |
| - |
389 |
| - if not allowed: |
390 |
| - raise LimitExceededError( |
391 |
| - retry_after_ms=int(1000 * (time_allowed - time_now_s)) |
392 |
| - ) |
| 377 | + await self._join_rate_limiter_local.ratelimit(requester) |
393 | 378 |
|
394 | 379 | result_event = await self.event_creation_handler.handle_new_client_event(
|
395 | 380 | requester,
|
@@ -835,19 +820,10 @@ async def update_membership_locked(
|
835 | 820 | )
|
836 | 821 | if remote_join:
|
837 | 822 | if ratelimit:
|
838 |
| - time_now_s = self.clock.time() |
839 |
| - ( |
840 |
| - allowed, |
841 |
| - time_allowed, |
842 |
| - ) = await self._join_rate_limiter_remote.can_do_action( |
| 823 | + await self._join_rate_limiter_remote.ratelimit( |
843 | 824 | requester,
|
844 | 825 | )
|
845 | 826 |
|
846 |
| - if not allowed: |
847 |
| - raise LimitExceededError( |
848 |
| - retry_after_ms=int(1000 * (time_allowed - time_now_s)) |
849 |
| - ) |
850 |
| - |
851 | 827 | inviter = await self._get_inviter(target.to_string(), room_id)
|
852 | 828 | if inviter and not self.hs.is_mine(inviter):
|
853 | 829 | remote_room_hosts.append(inviter.domain)
|
|
0 commit comments