mirror of
https://github.com/element-hq/synapse.git
synced 2026-01-11 19:56:31 +00:00
Fix media creation being ratelimited for appservices (#19335)
Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
This commit is contained in:
parent
1500733f4a
commit
ac6463c6da
2 changed files with 11 additions and 9 deletions
1
changelog.d/19335.bugfix
Normal file
1
changelog.d/19335.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fixed parallel calls to `/_matrix/media/v1/create` being ratelimited for appservices even if `rate_limited: false` was set in the registration. Contributed by @tulir @ Beeper.
|
||||
|
|
@ -60,15 +60,16 @@ class CreateResource(RestServlet):
|
|||
# If the create media requests for the user are over the limit, drop them.
|
||||
await self._create_media_rate_limiter.ratelimit(requester)
|
||||
|
||||
(
|
||||
reached_pending_limit,
|
||||
first_expiration_ts,
|
||||
) = await self.media_repo.reached_pending_media_limit(requester.user)
|
||||
if reached_pending_limit:
|
||||
raise LimitExceededError(
|
||||
limiter_name="max_pending_media_uploads",
|
||||
retry_after_ms=first_expiration_ts - self.clock.time_msec(),
|
||||
)
|
||||
if not requester.app_service or requester.app_service.is_rate_limited():
|
||||
(
|
||||
reached_pending_limit,
|
||||
first_expiration_ts,
|
||||
) = await self.media_repo.reached_pending_media_limit(requester.user)
|
||||
if reached_pending_limit:
|
||||
raise LimitExceededError(
|
||||
limiter_name="max_pending_media_uploads",
|
||||
retry_after_ms=first_expiration_ts - self.clock.time_msec(),
|
||||
)
|
||||
|
||||
content_uri, unused_expires_at = await self.media_repo.create_media_id(
|
||||
requester.user
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue