Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond with a 429 instead of 500 when exceeding invite rate limit #529

Merged
merged 3 commits into from
Nov 18, 2022

Conversation

squahtx
Copy link
Contributor

@squahtx squahtx commented Nov 18, 2022

No description provided.

@squahtx squahtx requested a review from a team as a code owner November 18, 2022 15:20
logger.info(
"Store invite request from %s to %s, in %s", sender, address, roomId
)

try:
self.sydent.email_sender_ratelimiter.ratelimit(sender)
except LimitExceededException:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to make the exception inherit from MatrixRestError so that it automatically does the right thing?

except MatrixRestError as e:
request.setResponseCode(e.httpStatus)
return dict_to_json_bytes({"errcode": e.errcode, "error": e.error})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the change in acfc89d

@erikjohnston erikjohnston merged commit 894883f into main Nov 18, 2022
@erikjohnston erikjohnston deleted the squah/ratelimit_invites_with_429 branch November 18, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants