Skip to content

Remove jackson from UpdateMessageData#1938

Open
SessionHero01 wants to merge 4 commits intodevfrom
remove-jackson-sealed-data
Open

Remove jackson from UpdateMessageData#1938
SessionHero01 wants to merge 4 commits intodevfrom
remove-jackson-sealed-data

Conversation

@SessionHero01
Copy link
Collaborator

This unfortunately introduces some access to the singleton MessagingModuleConfiguration, however we will be moving away from UpdateMessageData soon.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request removes the Jackson dependency from UpdateMessageData and replaces it with kotlinx.serialization. The change involves updating the serialization annotations from Jackson's @JsonTypeInfo and @JsonSubTypes to kotlinx.serialization's @Serializable, @JsonClassDiscriminator, and @SerialName. To support this migration, a Json parameter is now required for the fromJSON and toJSON methods, which is passed via dependency injection in most places. Where dependency injection is not available (such as in MessageRecord.java and OpenGroupInvitationView.kt), the PR temporarily uses the MessagingModuleConfiguration singleton to access the Json instance, which is acknowledged as a temporary solution in the PR description.

Changes:

  • Migrated UpdateMessageData from Jackson to kotlinx.serialization with appropriate annotations
  • Updated all call sites to pass the Json instance parameter to serialization methods
  • Temporarily introduced singleton access in two locations where dependency injection is not available

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageData.kt Core migration: replaced Jackson annotations with kotlinx.serialization annotations and updated serialization methods to accept Json parameter
app/src/main/java/org/thoughtcrime/securesms/database/model/MessageRecord.java Updated to use singleton access to Json instance for deserialization
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/OpenGroupInvitationView.kt Updated to use singleton access to Json instance for deserialization
app/src/main/java/org/thoughtcrime/securesms/repository/DefaultConversationRepository.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/thoughtcrime/securesms/conversation/v2/utilities/ResendMessageUtilities.kt Updated to inject and pass Json parameter via dependency injection
app/src/main/java/org/session/libsession/messaging/messages/signal/OutgoingTextMessage.kt Updated to pass Json parameter to serialization method
app/src/main/java/org/session/libsession/messaging/messages/signal/IncomingTextMessage.kt Updated to pass Json parameter to serialization method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +120 to +121
return getGroupUpdateMessage() != null &&
getGroupUpdateMessage().getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated;
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Calling getGroupUpdateMessage() twice will cause JSON deserialization to occur twice on each invocation. Consider storing the result in a local variable to avoid redundant parsing.

Suggested change
return getGroupUpdateMessage() != null &&
getGroupUpdateMessage().getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated;
UpdateMessageData message = getGroupUpdateMessage();
return message != null &&
message.getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated;

Copilot uses AI. Check for mistakes.
Comment on lines +156 to 161
fun fromJSON(json: Json, value: String): UpdateMessageData? {
return runCatching {
json.decodeFromString<UpdateMessageData>(value)
}.onFailure { Log.e(TAG, "Error decoding updateMessageData", it) }
.getOrNull()
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The migration from Jackson to kotlinx.serialization changes the JSON serialization implementation. While both use "@type" as the discriminator field, there may be subtle differences in formatting or behavior that could affect backward compatibility with existing messages in the database. Consider adding tests to verify that messages serialized with the old Jackson format can still be deserialized correctly with the new kotlinx.serialization implementation, or document if this has been verified.

Copilot uses AI. Check for mistakes.
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.

1 participant