mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-16 03:11:28 +00:00
Initial squash merge for strings
This commit is contained in:
@@ -10,6 +10,7 @@ interface LokiAPIDatabaseProtocol {
|
||||
fun getSnodePool(): Set<Snode>
|
||||
fun setSnodePool(newValue: Set<Snode>)
|
||||
fun getOnionRequestPaths(): List<List<Snode>>
|
||||
fun clearSnodePool()
|
||||
fun clearOnionRequestPaths()
|
||||
fun setOnionRequestPaths(newValue: List<List<Snode>>)
|
||||
fun getSwarm(publicKey: String): Set<Snode>?
|
||||
|
@@ -35,7 +35,7 @@ public class SignalServiceGroup {
|
||||
UNKNOWN,
|
||||
UPDATE,
|
||||
DELIVER,
|
||||
QUIT,
|
||||
MEMBER_LEFT,
|
||||
REQUEST_INFO,
|
||||
CREATION,
|
||||
NAME_CHANGE,
|
||||
|
@@ -115,18 +115,26 @@ object HTTP {
|
||||
}
|
||||
Verb.DELETE -> request.delete()
|
||||
}
|
||||
lateinit var response: Response
|
||||
try {
|
||||
val connection: OkHttpClient = if (timeout != HTTP.timeout) { // Custom timeout
|
||||
if (useSeedNodeConnection) {
|
||||
throw IllegalStateException("Setting a custom timeout is only allowed for requests to snodes.")
|
||||
return try {
|
||||
when {
|
||||
// Custom timeout
|
||||
timeout != HTTP.timeout -> {
|
||||
if (useSeedNodeConnection) {
|
||||
throw IllegalStateException("Setting a custom timeout is only allowed for requests to snodes.")
|
||||
}
|
||||
getDefaultConnection(timeout)
|
||||
}
|
||||
useSeedNodeConnection -> seedNodeConnection
|
||||
else -> defaultConnection
|
||||
}.newCall(request.build()).execute().use { response ->
|
||||
when (val statusCode = response.code) {
|
||||
200 -> response.body!!.bytes()
|
||||
else -> {
|
||||
Log.d("Loki", "${verb.rawValue} request to $url failed with status code: $statusCode.")
|
||||
throw HTTPRequestFailedException(statusCode, null)
|
||||
}
|
||||
}
|
||||
getDefaultConnection(timeout)
|
||||
} else {
|
||||
if (useSeedNodeConnection) seedNodeConnection else defaultConnection
|
||||
}
|
||||
|
||||
response = connection.newCall(request.build()).execute()
|
||||
} catch (exception: Exception) {
|
||||
Log.d("Loki", "${verb.rawValue} request to $url failed due to error: ${exception.localizedMessage}.")
|
||||
|
||||
@@ -135,14 +143,5 @@ object HTTP {
|
||||
// Override the actual error so that we can correctly catch failed requests in OnionRequestAPI
|
||||
throw HTTPRequestFailedException(0, null, "HTTP request failed due to: ${exception.message}")
|
||||
}
|
||||
return when (val statusCode = response.code) {
|
||||
200 -> {
|
||||
response.body!!.bytes()
|
||||
}
|
||||
else -> {
|
||||
Log.d("Loki", "${verb.rawValue} request to $url failed with status code: $statusCode.")
|
||||
throw HTTPRequestFailedException(statusCode, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package org.session.libsignal.utilities
|
||||
|
||||
class Snode(val address: String, val port: Int, val publicKeySet: KeySet?) {
|
||||
class Snode(val address: String, val port: Int, val publicKeySet: KeySet?, val version: String) {
|
||||
val ip: String get() = address.removePrefix("https://")
|
||||
|
||||
public enum class Method(val rawValue: String) {
|
||||
|
Reference in New Issue
Block a user