Compute via param from list utility method
This commit is contained in:
parent
b75d0cbfc6
commit
d04cbadd04
|
@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.session.permalinks
|
|||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import java.net.URLEncoder
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class PermalinkFactory @Inject constructor(
|
||||
|
@ -49,7 +48,7 @@ internal class PermalinkFactory @Inject constructor(
|
|||
append(MATRIX_TO_URL_BASE)
|
||||
append(escape(roomId))
|
||||
append(
|
||||
via?.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
||||
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.computeViaParams(it) }
|
||||
?: viaParameterFinder.computeViaParams(userId, roomId)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ internal class ViaParameterFinder @Inject constructor(
|
|||
.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
||||
}
|
||||
|
||||
fun computeViaParams(viaList: List<String>): String {
|
||||
return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
||||
}
|
||||
|
||||
fun computeViaParams(userId: String, roomId: String, max: Int): List<String> {
|
||||
val userHomeserver = userId.substringAfter(":")
|
||||
return getUserIdsOfJoinedMembers(roomId)
|
||||
|
|
Loading…
Reference in New Issue