Conversation
There was a problem hiding this comment.
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
UpdateMessageDatafrom Jackson to kotlinx.serialization with appropriate annotations - Updated all call sites to pass the
Jsoninstance 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.
| return getGroupUpdateMessage() != null && | ||
| getGroupUpdateMessage().getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated; |
There was a problem hiding this comment.
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.
| return getGroupUpdateMessage() != null && | |
| getGroupUpdateMessage().getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated; | |
| UpdateMessageData message = getGroupUpdateMessage(); | |
| return message != null && | |
| message.getKind() instanceof UpdateMessageData.Kind.GroupExpirationUpdated; |
| fun fromJSON(json: Json, value: String): UpdateMessageData? { | ||
| return runCatching { | ||
| json.decodeFromString<UpdateMessageData>(value) | ||
| }.onFailure { Log.e(TAG, "Error decoding updateMessageData", it) } | ||
| .getOrNull() | ||
| } |
There was a problem hiding this comment.
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.
This unfortunately introduces some access to the singleton
MessagingModuleConfiguration, however we will be moving away fromUpdateMessageDatasoon.