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
Stop shadow-banned users from sending non-member events. #8142
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 support for shadow-banning users (ignoring any message send requests). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,9 @@ async def upgrade_room( | |
|
||
Returns: | ||
the new room id | ||
|
||
Raises: | ||
ShadowBanError if the requester is shadow-banned. | ||
""" | ||
await self.ratelimit(requester) | ||
|
||
|
@@ -171,6 +174,15 @@ async def upgrade_room( | |
async def _upgrade_room( | ||
self, requester: Requester, old_room_id: str, new_version: RoomVersion | ||
): | ||
""" | ||
Args: | ||
requester: the user requesting the upgrade | ||
old_room_id: the id of the room to be replaced | ||
new_versions: the version to upgrade the room to | ||
|
||
Raises: | ||
ShadowBanError if the requester is shadow-banned. | ||
Comment on lines
+183
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should catch here and just create a new room for the shadow-banned person instead of continuing to raise There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly, or just no-op. I think it'll be a pretty rare case given you need to be a mod to upgrade a room. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. This does get caught at the REST layer and a fake room ID is returned. |
||
""" | ||
user_id = requester.user.to_string() | ||
|
||
# start by allocating a new room id | ||
|
@@ -257,6 +269,9 @@ async def _update_upgraded_room_pls( | |
old_room_id: the id of the room to be replaced | ||
new_room_id: the id of the replacement room | ||
old_room_state: the state map for the old room | ||
|
||
Raises: | ||
ShadowBanError if the requester is shadow-banned. | ||
""" | ||
old_room_pl_event_id = old_room_state.get((EventTypes.PowerLevels, "")) | ||
|
||
|
@@ -829,11 +844,13 @@ def create(etype: str, content: JsonDict, **kwargs) -> JsonDict: | |
async def send(etype: str, content: JsonDict, **kwargs) -> int: | ||
event = create(etype, content, **kwargs) | ||
logger.debug("Sending %s in new room", etype) | ||
# Allow these events to be sent even if the user is shadow-banned to | ||
# allow the room creation to complete. | ||
( | ||
_, | ||
last_stream_id, | ||
) = await self.event_creation_handler.create_and_send_nonmember_event( | ||
creator, event, ratelimit=False | ||
creator, event, ratelimit=False, ignore_shadow_ban=True, | ||
) | ||
return last_stream_id | ||
|
||
|
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
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.
Previously this did not get caught and kept raising.