Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface StorageProtocol {
// Servers
fun setServerCapabilities(server: String, capabilities: List<String>)
fun getServerCapabilities(server: String): List<String>?
fun clearServerCapabilities(server: String)

// Open Groups
suspend fun addOpenGroup(urlAsString: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,15 @@ object OpenGroupApi {
x25519PublicKey = serverPublicKey
)
} catch (e: Exception) {
//todo ONION handle the case where we get a 400 with "Invalid authentication: this server requires the use of blinded ids" - call capabilities once and retry < FANCHAO
when (e) {
is OnionError -> Log.e("SOGS", "Failed onion request: ${e.message}", e)
is OnionError -> {
Log.e("SOGS", "Failed onion request: ${e.message}", e)

if (e.status?.code == 400 &&
e.status.bodyText?.contains("Invalid authentication: this server requires the use of blinded ids", ignoreCase = true) == true) {
MessagingModuleConfiguration.shared.storage.clearServerCapabilities(request.server)
}
}
else -> Log.e("SOGS", "Failed onion request", e)
}
throw e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ class LokiAPIDatabase(context: Context, helper: Provider<SQLCipherOpenHelper>) :
}?.split(",")
}

fun clearServerCapabilities(serverName: String) {
writableDatabase.delete(serverCapabilitiesTable, "$server = ?", wrap(serverName))
}

fun setLastInboxMessageId(serverName: String, newValue: Long) {
val database = writableDatabase
val row = wrap(mapOf(server to serverName, lastInboxMessageServerId to newValue.toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,10 @@ open class Storage @Inject constructor(
return lokiAPIDatabase.getServerCapabilities(server)
}

override fun clearServerCapabilities(server: String) {
lokiAPIDatabase.clearServerCapabilities(server)
}

override fun getAllGroups(includeInactive: Boolean): List<GroupRecord> {
return groupDatabase.getAllGroups(includeInactive)
}
Expand Down