From 2b6bfc1ebc8a3ae89d68d23fde5c5cba7ff847bf Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Mon, 4 Jul 2022 18:00:30 +0200 Subject: [PATCH] Create local events using local echo --- .../session/room/create/CreateLocalRoomTask.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomTask.kt index eb35dd2387..94c300c3c3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomTask.kt @@ -24,6 +24,7 @@ import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.session.events.model.Content import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType +import org.matrix.android.sdk.api.session.events.model.LocalEcho import org.matrix.android.sdk.api.session.events.model.toContent import org.matrix.android.sdk.api.session.room.model.GuestAccess import org.matrix.android.sdk.api.session.room.model.Membership @@ -58,7 +59,6 @@ import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection import org.matrix.android.sdk.internal.task.Task import org.matrix.android.sdk.internal.util.awaitTransaction import org.matrix.android.sdk.internal.util.time.Clock -import java.util.UUID import javax.inject.Inject internal interface CreateLocalRoomTask : Task @@ -185,13 +185,13 @@ internal class DefaultCreateLocalRoomTask @Inject constructor( val invitedUsers = createRoomBody.invitedUserIds.orEmpty() .mapNotNull { tryOrNull { userService.resolveUser(it) } } - val createRoomEvent = createFakeEvent( + val createRoomEvent = createLocalEvent( type = EventType.STATE_ROOM_CREATE, content = RoomCreateContent( creator = userId ).toContent() ) - val myRoomMemberEvent = createFakeEvent( + val myRoomMemberEvent = createLocalEvent( type = EventType.STATE_ROOM_MEMBER, content = RoomMemberContent( membership = Membership.JOIN, @@ -201,7 +201,7 @@ internal class DefaultCreateLocalRoomTask @Inject constructor( stateKey = userId ) val roomMemberEvents = invitedUsers.map { - createFakeEvent( + createLocalEvent( type = EventType.STATE_ROOM_MEMBER, content = RoomMemberContent( isDirect = createRoomBody.isDirect.orFalse(), @@ -216,7 +216,7 @@ internal class DefaultCreateLocalRoomTask @Inject constructor( return buildList { add(createRoomEvent) add(myRoomMemberEvent) - addAll(createRoomBody.initialStates.orEmpty().map { createFakeEvent(it.type, it.content, it.stateKey) }) + addAll(createRoomBody.initialStates.orEmpty().map { createLocalEvent(it.type, it.content, it.stateKey) }) addAll(roomMemberEvents) } } @@ -230,14 +230,14 @@ internal class DefaultCreateLocalRoomTask @Inject constructor( * * @return a fake event */ - private fun createFakeEvent(type: String?, content: Content?, stateKey: String? = ""): Event { + private fun createLocalEvent(type: String?, content: Content?, stateKey: String? = ""): Event { return Event( type = type, senderId = userId, stateKey = stateKey, content = content, originServerTs = clock.epochMillis(), - eventId = UUID.randomUUID().toString() + eventId = LocalEcho.createLocalEchoId() ) }