Code review
This commit is contained in:
parent
60dee6eea3
commit
871360754e
|
@ -33,8 +33,8 @@ internal class DefaultPermalinkService @Inject constructor(
|
||||||
return permalinkFactory.createPermalink(id)
|
return permalinkFactory.createPermalink(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createRoomPermalink(roomId: String, via: List<String>?): String? {
|
override fun createRoomPermalink(roomId: String, viaServers: List<String>?): String? {
|
||||||
return permalinkFactory.createRoomPermalink(roomId, via)
|
return permalinkFactory.createRoomPermalink(roomId, viaServers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createPermalink(roomId: String, eventId: String): String {
|
override fun createPermalink(roomId: String, eventId: String): String {
|
||||||
|
|
|
@ -48,7 +48,7 @@ internal class PermalinkFactory @Inject constructor(
|
||||||
append(MATRIX_TO_URL_BASE)
|
append(MATRIX_TO_URL_BASE)
|
||||||
append(escape(roomId))
|
append(escape(roomId))
|
||||||
append(
|
append(
|
||||||
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.computeViaParams(it) }
|
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.asUrlViaParameters(it) }
|
||||||
?: viaParameterFinder.computeViaParams(userId, roomId)
|
?: viaParameterFinder.computeViaParams(userId, roomId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,10 @@ internal class ViaParameterFinder @Inject constructor(
|
||||||
* current user one.
|
* current user one.
|
||||||
*/
|
*/
|
||||||
fun computeViaParams(userId: String, roomId: String): String {
|
fun computeViaParams(userId: String, roomId: String): String {
|
||||||
return computeViaParams(userId, roomId, 3)
|
return asUrlViaParameters(computeViaParams(userId, roomId, 3))
|
||||||
.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun computeViaParams(viaList: List<String>): String {
|
fun asUrlViaParameters(viaList: List<String>): String {
|
||||||
return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
return viaList.joinToString(prefix = "?via=", separator = "&via=") { URLEncoder.encode(it, "utf-8") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue