Code review

This commit is contained in:
Valere 2021-05-28 11:12:10 +02:00
parent 60dee6eea3
commit 871360754e
3 changed files with 5 additions and 6 deletions

View file

@ -33,8 +33,8 @@ internal class DefaultPermalinkService @Inject constructor(
return permalinkFactory.createPermalink(id)
}
override fun createRoomPermalink(roomId: String, via: List<String>?): String? {
return permalinkFactory.createRoomPermalink(roomId, via)
override fun createRoomPermalink(roomId: String, viaServers: List<String>?): String? {
return permalinkFactory.createRoomPermalink(roomId, viaServers)
}
override fun createPermalink(roomId: String, eventId: String): String {

View file

@ -48,7 +48,7 @@ internal class PermalinkFactory @Inject constructor(
append(MATRIX_TO_URL_BASE)
append(escape(roomId))
append(
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.computeViaParams(it) }
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.asUrlViaParameters(it) }
?: viaParameterFinder.computeViaParams(userId, roomId)
)
}

View file

@ -39,11 +39,10 @@ internal class ViaParameterFinder @Inject constructor(
* current user one.
*/
fun computeViaParams(userId: String, roomId: String): String {
return computeViaParams(userId, roomId, 3)
.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
return asUrlViaParameters(computeViaParams(userId, roomId, 3))
}
fun computeViaParams(viaList: List<String>): String {
fun asUrlViaParameters(viaList: List<String>): String {
return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
}