-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reduce inconsistencies between codepaths for membership and non-membership events. #8463
Changes from 5 commits
b520a1b
2ee302d
fd02822
e775b5b
103f729
903fcd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reduce inconsistencies between codepaths for membership and non-membership events. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,16 +188,6 @@ async def _local_membership_update( | |
require_consent=require_consent, | ||
) | ||
|
||
# Check if this event matches the previous membership event for the user. | ||
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. Is there any concern that removing this check from earlier on might cause odd errors (e.g. rate limiting or in 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. In this case, the only difference between doing it here and at the start of In |
||
duplicate = await self.event_creation_handler.deduplicate_state_event( | ||
event, context | ||
) | ||
if duplicate is not None: | ||
# Discard the new event since this membership change is a no-op. | ||
# we know it was persisted, so must have a stream ordering. | ||
assert duplicate.internal_metadata.stream_ordering | ||
return duplicate.event_id, duplicate.internal_metadata.stream_ordering | ||
|
||
prev_state_ids = await context.get_prev_state_ids() | ||
|
||
prev_member_event_id = prev_state_ids.get((EventTypes.Member, user_id), None) | ||
|
@@ -222,7 +212,7 @@ async def _local_membership_update( | |
retry_after_ms=int(1000 * (time_allowed - time_now_s)) | ||
) | ||
|
||
stream_id = await self.event_creation_handler.handle_new_client_event( | ||
result_event = await self.event_creation_handler.handle_new_client_event( | ||
requester, event, context, extra_users=[target], ratelimit=ratelimit, | ||
) | ||
|
||
|
@@ -232,7 +222,9 @@ async def _local_membership_update( | |
if prev_member_event.membership == Membership.JOIN: | ||
await self._user_left_room(target, room_id) | ||
|
||
return event.event_id, stream_id | ||
# we know it was persisted, so should have a stream ordering | ||
assert result_event.internal_metadata.stream_ordering | ||
return result_event.event_id, result_event.internal_metadata.stream_ordering | ||
|
||
async def copy_room_tags_and_direct_to_room( | ||
self, old_room_id, new_room_id, user_id | ||
|
@@ -673,12 +665,6 @@ async def send_membership_event( | |
else: | ||
requester = types.create_requester(target_user) | ||
|
||
prev_event = await self.event_creation_handler.deduplicate_state_event( | ||
event, context | ||
) | ||
if prev_event is not None: | ||
return | ||
|
||
prev_state_ids = await context.get_prev_state_ids() | ||
if event.membership == Membership.JOIN: | ||
if requester.is_guest: | ||
|
@@ -1186,10 +1172,13 @@ async def _locally_reject_invite( | |
|
||
context = await self.state_handler.compute_event_context(event) | ||
context.app_service = requester.app_service | ||
stream_id = await self.event_creation_handler.handle_new_client_event( | ||
result_event = await self.event_creation_handler.handle_new_client_event( | ||
requester, event, context, extra_users=[UserID.from_string(target_user)], | ||
) | ||
return event.event_id, stream_id | ||
# we know it was persisted, so must have a stream ordering | ||
assert result_event.internal_metadata.stream_ordering | ||
|
||
return result_event.event_id, result_event.internal_metadata.stream_ordering | ||
|
||
async def _user_left_room(self, target: UserID, room_id: str) -> None: | ||
"""Implements RoomMemberHandler._user_left_room | ||
|
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'm not sure this is really true? We do have code to handle them for invites, but I suppose those are handled before this point is reached.
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 guess... I'll add a couple more words.