This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add an admin API to manage ratelimit for a specific user #9648
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a2769b0
Add an admin API to manage ratelimit for a specific user
dklimpel 9762a50
changelog and small fix for mypy because of broken dev
dklimpel ce45076
lint
dklimpel 44f9470
Typo in tests
dklimpel a96bd75
Merge remote-tracking branch 'synapse/develop' into rate_limit
dklimpel c933cbb
Change `GET` if no custom ratelimit is set to `{}`
dklimpel c242bf7
lint
dklimpel 893acba
Merge remote-tracking branch 'synapse/develop' into rate_limit
dklimpel 40d0c21
Merge remote-tracking branch 'synapse/develop' into rate_limit
dklimpel a13722b
add conversion from `null` to `0`
dklimpel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add an admin API to manage ratelimit for a specific user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document that
0
ornull
mean ratelimiting is disabled? Or we should replace0
withnull
(or vice versa) before returning the values, for consistency sake?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i read the code correctly, then
null
is better for deactivating, as it breaks the processing sooner!?But I do not like that a
null
value disable ratelimit.0
is more understandable.What's your opinion?
Should I update
if not override.messages_per_second:
toif not override.messages_per_second or override.messages_per_second == 0:
?synapse/synapse/handlers/_base.py
Lines 102 to 108 in 5b26899
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not override.messages_per_second:
andif not override.messages_per_second or override.messages_per_second == 0:
are equivalent here (since bothNone
and0
are falsey in python), which is why we've ended up in a situation where0
andNone
mean the same thing anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only thing we might want to do here is to change
null
to0
(or vice versa) when we return the values from the API, for consistency. I don't really mind though.(The fact that we treat
0
andnull
the same is a bit awful, but untangling that may be a bit of a mess)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably just cast to an int to always return
0
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can do it.
Should I do the conversion from
None
to0
only in admin API or direct in storeget_ratelimit_for_user
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably do it in the API for now, just to avoid unnecessarily changing things used by lots of places.