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

Commit

Permalink
fix up for #14882
Browse files Browse the repository at this point in the history
* the filter for partial state rooms in `_clean_room_for_join_txn` has
  been replaced with a host membership check in `_do_invite_join`.
* `_do_invite_join` can no longer raise a `PartialStateConflictError`.
  • Loading branch information
Sean Quah committed Jan 27, 2023
1 parent 20d5d34 commit 9a934c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
23 changes: 5 additions & 18 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@
GuestAccess,
Membership,
)
from synapse.api.errors import (
AuthError,
Codes,
PartialStateConflictError,
ShadowBanError,
SynapseError,
)
from synapse.api.errors import AuthError, Codes, ShadowBanError, SynapseError
from synapse.api.ratelimiting import Ratelimiter
from synapse.event_auth import get_named_level, get_power_level_event
from synapse.events import EventBase
Expand Down Expand Up @@ -201,8 +195,6 @@ async def _remote_join(
Raises:
NoKnownServersError: if remote_room_hosts does not contain a server joined to
the room.
PartialStateConflictError: if the room was un-partial stated in the meantime,
a local room join should be done instead.
"""
raise NotImplementedError()

Expand Down Expand Up @@ -990,16 +982,11 @@ async def update_membership_locked(
if requester.is_guest:
content["kind"] = "guest"

try:
remote_join_response = await self._remote_join(
requester, remote_room_hosts, room_id, target, content
)
remote_join_response = await self._remote_join(
requester, remote_room_hosts, room_id, target, content
)

return remote_join_response
except PartialStateConflictError:
# Room has been un-partial stated in the meantime, let's continue
# the code flow to trigger a local join through _local_membership_update.
pass
return remote_join_response

elif effective_membership_state == Membership.LEAVE:
if not is_host_in_room:
Expand Down
22 changes: 8 additions & 14 deletions synapse/handlers/room_member_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from http import HTTPStatus
from typing import TYPE_CHECKING, List, Optional, Tuple

from synapse.api.errors import PartialStateConflictError, SynapseError
from synapse.api.errors import SynapseError
from synapse.handlers.room_member import NoKnownServersError, RoomMemberHandler
from synapse.replication.http.membership import (
ReplicationRemoteJoinRestServlet as ReplRemoteJoin,
Expand Down Expand Up @@ -55,19 +55,13 @@ async def _remote_join(
if len(remote_room_hosts) == 0:
raise NoKnownServersError()

try:
ret = await self._remote_join_client(
requester=requester,
remote_room_hosts=remote_room_hosts,
room_id=room_id,
user_id=user.to_string(),
content=content,
)
except SynapseError as e:
if e.code == HTTPStatus.CONFLICT:
raise PartialStateConflictError()
else:
raise e
ret = await self._remote_join_client(
requester=requester,
remote_room_hosts=remote_room_hosts,
room_id=room_id,
user_id=user.to_string(),
content=content,
)

return ret["event_id"], ret["stream_id"]

Expand Down
7 changes: 1 addition & 6 deletions synapse/storage/databases/main/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,12 +2016,7 @@ async def clean_room_for_join(self, room_id: str) -> None:
)

def _clean_room_for_join_txn(self, txn: LoggingTransaction, room_id: str) -> None:
query = """
DELETE FROM event_forward_extremities
WHERE room_id = ? AND room_id NOT IN (
SELECT room_id FROM partial_state_rooms
)
"""
query = "DELETE FROM event_forward_extremities WHERE room_id = ?"

txn.execute(query, (room_id,))
txn.call_after(self.get_latest_event_ids_in_room.invalidate, (room_id,))
Expand Down

0 comments on commit 9a934c1

Please sign in to comment.