Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Return 403 when GETing /joined_members after leaving #13374

Merged
merged 29 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3c10c80
remove constantly lib use and switch to enums.
andrewdoh May 4, 2022
9a450fc
add changlog for pr 12624.
andrewdoh May 4, 2022
317065a
Fix capitalization of sentence and add credit.
andrewdoh May 4, 2022
ed6b772
resolve conflict with mypy.ini, pulled from upstream.
andrewdoh May 4, 2022
2b1fe9a
update function docstring description to new updated enum values.
andrewdoh May 4, 2022
7c9e5db
Update changelog.
clokep May 4, 2022
9dfe96a
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jun 6, 2022
10ef848
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jul 6, 2022
32759dc
add room_type to list room and room details API response.
andrewdoh Jul 7, 2022
db7010b
refactor changelog file to expected number.
andrewdoh Jul 7, 2022
24004a7
add room_type definition and examples to documentation.
andrewdoh Jul 7, 2022
453321a
make room_type definition in documentation more specific.
andrewdoh Jul 7, 2022
8cc95ae
remove old changelog file.
andrewdoh Jul 7, 2022
13e015a
refactored changelog file to features, and made various updates to de…
andrewdoh Jul 7, 2022
01c97a9
Update docs/admin_api/rooms.md
andrewdoh Jul 11, 2022
2162421
update the other room_type entry as well
anoadragon453 Jul 12, 2022
7dd8b26
Make use of the newly exposed room_type in _build_room_entry
anoadragon453 Jul 12, 2022
3fca4c0
Revert "Make use of the newly exposed room_type in _build_room_entry"
anoadragon453 Jul 12, 2022
17d244d
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jul 15, 2022
f5cff52
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jul 22, 2022
25b3b04
Change joined_member endpoint to return NotImplementedError -> Synaps…
andrewdoh Jul 24, 2022
05fc5e7
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jul 24, 2022
ba10ef5
add changelog file for PR 13374.
andrewdoh Jul 24, 2022
c9bb0db
add type annotation for test function.
andrewdoh Jul 24, 2022
cc8ac71
Update tests/rest/admin/test_room.py
andrewdoh Jul 25, 2022
02f0681
Update changelog.d/13374.bugfix
andrewdoh Jul 25, 2022
7248f39
Update tests/rest/admin/test_room.py
andrewdoh Jul 25, 2022
b2f418d
update per feedback. made error message returned more descriptive and…
andrewdoh Jul 25, 2022
d9a1172
Merge remote-tracking branch 'upstream/develop' into develop
andrewdoh Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13374.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug when user tries getting joined_members after already having left the room. Contributed by @andrewdoh.
andrewdoh marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 4 additions & 2 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ async def get_joined_members(self, requester: Requester, room_id: str) -> dict:
room_id, user_id, allow_departed_users=True
)
if membership != Membership.JOIN:
raise NotImplementedError(
"Getting joined members after leaving is not implemented"
raise SynapseError(
code=403,
errcode=Codes.FORBIDDEN,
msg="Getting joined members after leaving is forbidden.",
andrewdoh marked this conversation as resolved.
Show resolved Hide resolved
)

users_with_profile = await self.store.get_users_in_room_with_profiles(room_id)
Expand Down
15 changes: 15 additions & 0 deletions tests/rest/admin/test_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,21 @@ def _set_canonical_alias(
tok=admin_user_tok,
)

def test_get_joined_members_after_leave_room(self) -> None:
"""Test that room members can be requested correctly"""
andrewdoh marked this conversation as resolved.
Show resolved Hide resolved

# create the room
user_1 = self.register_user("foo", "pass")
user_tok_1 = self.login("foo", "pass")
room_id_1 = self.helper.create_room_as(user_1, tok=user_tok_1)
self.helper.leave(room_id_1, user_1, tok=user_tok_1)

# delete the rooms and get joined roomed membership
url = f"/_matrix/client/r0/rooms/{room_id_1}/joined_members"
channel = self.make_request("GET", url.encode("ascii"), access_token=user_tok_1)
andrewdoh marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(HTTPStatus.FORBIDDEN, channel.code, msg=channel.json_body)
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])


class JoinAliasRoomTestCase(unittest.HomeserverTestCase):

Expand Down