Improve createRoomThreePidEvents for clarity

This commit is contained in:
Florian Renaud 2022-08-25 14:28:17 +02:00
parent eab4ebc3b1
commit cac4df7d66

View File

@ -156,7 +156,7 @@ internal class DefaultCreateLocalRoomStateEventsTask @Inject constructor(
* Generate the local state events related to the given third party invites, if any. * Generate the local state events related to the given third party invites, if any.
*/ */
private fun MutableList<Event>.createRoomThreePidEvents() { private fun MutableList<Event>.createRoomThreePidEvents() {
val threePidEvents = createRoomBody.invite3pids.orEmpty().map { body -> createRoomBody.invite3pids.orEmpty().forEach { body ->
val localThirdPartyInviteEvent = createLocalStateEvent( val localThirdPartyInviteEvent = createLocalStateEvent(
type = EventType.LOCAL_STATE_ROOM_THIRD_PARTY_INVITE, type = EventType.LOCAL_STATE_ROOM_THIRD_PARTY_INVITE,
content = LocalRoomThirdPartyInviteContent( content = LocalRoomThirdPartyInviteContent(
@ -168,11 +168,16 @@ internal class DefaultCreateLocalRoomStateEventsTask @Inject constructor(
) )
val thirdPartyInviteEvent = createLocalStateEvent( val thirdPartyInviteEvent = createLocalStateEvent(
type = EventType.STATE_ROOM_THIRD_PARTY_INVITE, 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) add(localThirdPartyInviteEvent)
}.flatten() add(thirdPartyInviteEvent)
addAll(threePidEvents) }
} }
/** /**