Skip to content

Conversation

@SessionHero01
Copy link
Collaborator

@SessionHero01 SessionHero01 commented Jan 27, 2026

This PR reorganises code around and makes use of the concept of ApiExecutor: different executors operate on different levels, and they normally just pass data down to another level for handling.

@SessionHero01 SessionHero01 marked this pull request as ready for review January 28, 2026 22:54
@@ -0,0 +1,3 @@
package org.thoughtcrime.securesms.api.error

class ClockOutOfSyncException : RuntimeException("Clock is out of sync is reported by a server") No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this level of abstraction for the COS

*
* Normally this is up to the caller to handle.
*/
class UnknownStatusCodeException(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unhandled instead of unknown?

)
return parseSnodePoolFromJsonBytes(responseBytes)
private suspend fun fetchSnodePoolFromSnode(snode: Snode): List<Snode> {
//TODO: Onion should request over onion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove this todo now

val parsed = parseSnodePoolFromJsonBytes(localBytes)
@Suppress("OPT_IN_USAGE")
val parsed: ListSnodeApi.Response = appContext.assets.open(LOCAL_SNODE_POOL_ASSET)
.use(json::decodeFromStream)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deserialise will fail - missing result

@@ -20,13 +19,4 @@ data class BatchResponse(val results: List<Item>, ) {
val isSnodeNoLongerPartOfSwarm: Boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be needed anymore now

.execute(
req = SnodeApiRequest(
snode = snodePoolStorage.getSnodePool().first { it !in pathCandidate },
api = getNetworkTimeApi.get()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should getNetworkTime be renamed to info?

item to result.map { response ->
when {
response.isSuccess() -> Unit
response.error == 403 -> throw NonRetryableException("Request failed: code = ${response.error}, message = ${response.message}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we missing some of these error handling cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants