Skip to content

Conversation

@ThomasSession
Copy link
Collaborator

SES-4678 - Community message duplication. This fixes an issues with the ix of Promises and coroutines. We want Promises out of the app, so this removes a bunch of them around the OpenGroupAPI and related classes

This also fixes an issue with removing reactions on other people's messages. There was confusion as to what the author is: The author of the reaction or of the message on which the reaction is added.

This also fixes a layout issue wit the reaction rail under the message, that would sometime appear in the middle

}

val response = getResponseBody(request, signRequest = true)
val reaction: AddReactionResponse = MessagingModuleConfiguration.shared.json.decodeFromStream(response.inputStream())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should close the input stream, even it's bytearray's input stream (same for the deleteReaction)

Suggested change
val reaction: AddReactionResponse = MessagingModuleConfiguration.shared.json.decodeFromStream(response.inputStream())
val reaction: AddReactionResponse = response.inputStream().use( MessagingModuleConfiguration.shared.json::decodeFromStream)

Comment on lines 547 to 548
@JvmStatic
fun deleteMessage(serverID: Long, room: String, server: String): Promise<Unit, Exception> {
suspend fun deleteMessage(serverID: Long, room: String, server: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can probably get rid of @JvmStatic: java is not going to be able to use this anyway

Comment on lines 400 to 402
} catch (exception: Exception) {
handleFailure(exception)
handleFailedMessageSend(message, exception)
throw exception
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there might be an issue here: if we are using coroutine, we want to be careful about CancellationException: it's a special exception used by coroutine to interrupt the flow. In most cases, we should not interpret it as an error, and should rethrow it right away

Suggested change
} catch (exception: Exception) {
handleFailure(exception)
handleFailedMessageSend(message, exception)
throw exception
} catch (exception: Exception) {
if (exception !is CancellationException) handleFailedMessageSend(message, exception)
throw exception

Comment on lines 1755 to 1760
OpenGroupApi.addReaction(
room = recipient.address.room,
server = recipient.address.serverUrl,
messageId = messageServerId,
emoji = emoji
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need try catch otherwise it will crash the app on error (Promise will silently ignore it but we can't with coroutine)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This will apply to all fire-and-forget cases

scope.launch {
try {
callManager.onNewOffer(sdp, callId, address)
} catch (e: Exception) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need special handling for CancellationException

viewModel.blindedPublicKey,
isResync = true
)
runCatching {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be inside the forEach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, no reason to fail all is one doesn't go through

OpenGroupApi.getDefaultServerCapabilities().map {
OpenGroupApi.getDefaultRoomsIfNeeded()
runCatching {
OpenGroupApi.getDefaultServerCapabilities().map {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting. map was previously used on a Promise and now it's used for the List, so now it will run getDefaultRoomsIfNeededmultiple times

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, this can happen sequentially

@ThomasSession ThomasSession merged commit 4901be7 into release/1.28.2 Oct 17, 2025
4 checks passed
@ThomasSession ThomasSession deleted the fix/ses-4678-repeated-sogs-messages branch October 17, 2025 03:45
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.

2 participants