mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Fixes
This commit is contained in:
parent
da0d2219d2
commit
9244a3089e
@ -29,6 +29,7 @@ import synapse.server
|
|||||||
import synapse.types
|
import synapse.types
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.api.errors import AuthError, Codes, SynapseError
|
from synapse.api.errors import AuthError, Codes, SynapseError
|
||||||
|
from synapse.storage.state import StateFilter
|
||||||
from synapse.types import RoomID, UserID
|
from synapse.types import RoomID, UserID
|
||||||
from synapse.util.async_helpers import Linearizer
|
from synapse.util.async_helpers import Linearizer
|
||||||
from synapse.util.distributor import user_joined_room, user_left_room
|
from synapse.util.distributor import user_joined_room, user_left_room
|
||||||
@ -223,6 +224,17 @@ class RoomMemberHandler(object):
|
|||||||
|
|
||||||
# Copy over direct message status and room tags if this is a join
|
# Copy over direct message status and room tags if this is a join
|
||||||
# on an upgraded room
|
# 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)
|
self.copy_room_tags_and_direct_to_room(old_room_id, room_id, user_id)
|
||||||
elif event.membership == Membership.LEAVE:
|
elif event.membership == Membership.LEAVE:
|
||||||
if prev_member_event_id:
|
if prev_member_event_id:
|
||||||
@ -249,18 +261,6 @@ class RoomMemberHandler(object):
|
|||||||
Returns:
|
Returns:
|
||||||
Deferred|None
|
Deferred|None
|
||||||
"""
|
"""
|
||||||
# Check if this is an upgraded room
|
|
||||||
state_ids = yield self.store.get_filtered_current_state_ids(
|
|
||||||
new_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"]
|
|
||||||
|
|
||||||
# Retrieve user account data for predecessor room
|
# Retrieve user account data for predecessor room
|
||||||
user_account_data, _ = yield self.store.get_account_data_for_user(
|
user_account_data, _ = yield self.store.get_account_data_for_user(
|
||||||
user_id,
|
user_id,
|
||||||
@ -290,7 +290,7 @@ class RoomMemberHandler(object):
|
|||||||
# Copy each room tag to the new room
|
# Copy each room tag to the new room
|
||||||
for tag, tag_content in room_tags.items():
|
for tag, tag_content in room_tags.items():
|
||||||
yield self.store.add_tag_to_room(
|
yield self.store.add_tag_to_room(
|
||||||
user_id, room_id, tag, tag_content
|
user_id, new_room_id, tag, tag_content
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user