mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-08 04:14:57 -04:00
Add a ratelimiter for 3pid invite (#11892)
This commit is contained in:
parent
833247553f
commit
d80d39b035
4 changed files with 31 additions and 1 deletions
|
@ -116,6 +116,13 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
|||
burst_count=hs.config.ratelimiting.rc_invites_per_user.burst_count,
|
||||
)
|
||||
|
||||
self._third_party_invite_limiter = Ratelimiter(
|
||||
store=self.store,
|
||||
clock=self.clock,
|
||||
rate_hz=hs.config.ratelimiting.rc_third_party_invite.per_second,
|
||||
burst_count=hs.config.ratelimiting.rc_third_party_invite.burst_count,
|
||||
)
|
||||
|
||||
self.request_ratelimiter = hs.get_request_ratelimiter()
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -1295,7 +1302,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
|||
|
||||
# We need to rate limit *before* we send out any 3PID invites, so we
|
||||
# can't just rely on the standard ratelimiting of events.
|
||||
await self.request_ratelimiter.ratelimit(requester)
|
||||
await self._third_party_invite_limiter.ratelimit(requester)
|
||||
|
||||
can_invite = await self.third_party_event_rules.check_threepid_can_be_invited(
|
||||
medium, address, room_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue