fix: add support for non-standard ports in opengroupv2

This commit is contained in:
jubb 2021-05-04 15:52:08 +10:00
parent f3fa8626ed
commit d8e9e372d3
2 changed files with 7 additions and 1 deletions

View File

@ -95,7 +95,12 @@ class JoinPublicChatActivity : PassphraseRequiredActionBarActivity(), ScanQRCode
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
try { try {
val (threadID, groupID) = if (isV2OpenGroup) { val (threadID, groupID) = if (isV2OpenGroup) {
val server = HttpUrl.Builder().scheme(httpUrl.scheme()).host(httpUrl.host()).build() val server = HttpUrl.Builder().scheme(httpUrl.scheme()).host(httpUrl.host()).apply {
if (httpUrl.port() != 80 || httpUrl.port() != 443) {
// non-standard port, add to server
this.port(httpUrl.port())
}
}.build()
val group = OpenGroupUtilities.addGroup(this@JoinPublicChatActivity, server.toString().removeSuffix("/"), room!!, publicKey!!) val group = OpenGroupUtilities.addGroup(this@JoinPublicChatActivity, server.toString().removeSuffix("/"), room!!, publicKey!!)
val threadID = GroupManager.getOpenGroupThreadID(group.id, this@JoinPublicChatActivity) val threadID = GroupManager.getOpenGroupThreadID(group.id, this@JoinPublicChatActivity)
val groupID = GroupUtil.getEncodedOpenGroupID(group.id.toByteArray()) val groupID = GroupUtil.getEncodedOpenGroupID(group.id.toByteArray())

View File

@ -106,6 +106,7 @@ object OpenGroupAPIV2 {
val urlBuilder = HttpUrl.Builder() val urlBuilder = HttpUrl.Builder()
.scheme(parsed.scheme()) .scheme(parsed.scheme())
.host(parsed.host()) .host(parsed.host())
.port(parsed.port())
.addPathSegments(request.endpoint) .addPathSegments(request.endpoint)
if (request.verb == GET) { if (request.verb == GET) {