From cac4df7d664b1e081f9c9bb36d217afbb410b5c9 Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Thu, 25 Aug 2022 14:28:17 +0200 Subject: [PATCH] Improve createRoomThreePidEvents for clarity --- .../room/create/CreateLocalRoomStateEventsTask.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomStateEventsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomStateEventsTask.kt index 855e07eaf66..a9ff4970fee 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomStateEventsTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateLocalRoomStateEventsTask.kt @@ -156,7 +156,7 @@ internal class DefaultCreateLocalRoomStateEventsTask @Inject constructor( * Generate the local state events related to the given third party invites, if any. */ private fun MutableList.createRoomThreePidEvents() { - val threePidEvents = createRoomBody.invite3pids.orEmpty().map { body -> + createRoomBody.invite3pids.orEmpty().forEach { body -> val localThirdPartyInviteEvent = createLocalStateEvent( type = EventType.LOCAL_STATE_ROOM_THIRD_PARTY_INVITE, content = LocalRoomThirdPartyInviteContent( @@ -168,11 +168,16 @@ internal class DefaultCreateLocalRoomStateEventsTask @Inject constructor( ) val thirdPartyInviteEvent = createLocalStateEvent( type = EventType.STATE_ROOM_THIRD_PARTY_INVITE, - content = RoomThirdPartyInviteContent(body.address, null, null, null).toContent(), + content = RoomThirdPartyInviteContent( + displayName = body.address, + keyValidityUrl = null, + publicKey = null, + publicKeys = null + ).toContent(), ) - listOf(localThirdPartyInviteEvent, thirdPartyInviteEvent) - }.flatten() - addAll(threePidEvents) + add(localThirdPartyInviteEvent) + add(thirdPartyInviteEvent) + } } /**