mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-27 03:58:06 +03:00
Reuse predecessor method
This commit is contained in:
parent
9244a3089e
commit
1ce463963d
1 changed files with 8 additions and 12 deletions
|
@ -29,7 +29,6 @@ import synapse.server
|
|||
import synapse.types
|
||||
from synapse.api.constants import EventTypes, Membership
|
||||
from synapse.api.errors import AuthError, Codes, SynapseError
|
||||
from synapse.storage.state import StateFilter
|
||||
from synapse.types import RoomID, UserID
|
||||
from synapse.util.async_helpers import Linearizer
|
||||
from synapse.util.distributor import user_joined_room, user_left_room
|
||||
|
@ -224,18 +223,15 @@ class RoomMemberHandler(object):
|
|||
|
||||
# Copy over direct message status and room tags if this is a join
|
||||
# on an upgraded room
|
||||
# Check if this is an upgraded room
|
||||
state_ids = yield self.store.get_filtered_current_state_ids(
|
||||
room_id, StateFilter.from_types([(EventTypes.Create, "")]),
|
||||
)
|
||||
create_id = state_ids.get((EventTypes.Create, ""))
|
||||
if not create_id:
|
||||
return
|
||||
create_event = yield self.store.get_event(create_id)
|
||||
|
||||
if "predecessor" in create_event["content"]:
|
||||
old_room_id = create_event["content"]["predecessor"]["room_id"]
|
||||
self.copy_room_tags_and_direct_to_room(old_room_id, room_id, user_id)
|
||||
# Check if this is an upgraded room
|
||||
predecessor = yield self.store.get_room_predecessor(room_id)
|
||||
|
||||
if predecessor:
|
||||
# It is an upgraded room. Copy over old tags
|
||||
self.copy_room_tags_and_direct_to_room(
|
||||
predecessor["room_id"], room_id, user_id,
|
||||
)
|
||||
elif event.membership == Membership.LEAVE:
|
||||
if prev_member_event_id:
|
||||
prev_member_event = yield self.store.get_event(prev_member_event_id)
|
||||
|
|
Loading…
Reference in a new issue