-
Notifications
You must be signed in to change notification settings - Fork 927
[PM-26736] Fix push notification logout reason serialization #6116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ sealed class NotificationPayload { | |
| @JsonNames("Date", "date") | ||
| val date: ZonedDateTime?, | ||
|
|
||
| @JsonNames("PushNotificationLogOutReason", "pushNotificationLogOutReason") | ||
| @JsonNames("Reason", "reason") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Good field rename from ๐ The |
||
| val pushNotificationLogOutReason: PushNotificationLogOutReason?, | ||
| ) : NotificationPayload() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,22 @@ | ||
| package com.x8bit.bitwarden.data.platform.manager.model | ||
|
|
||
| import androidx.annotation.Keep | ||
| import com.bitwarden.core.data.serializer.BaseEnumeratedIntSerializer | ||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| /** | ||
| * Enumerated values to represent the possible reasons for a log out push notification | ||
| */ | ||
| @Serializable(with = PushNotificationLogOutReasonSerializer::class) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Excellent addition of the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Perfect addition of proper kotlinx.serialization support! The Using |
||
| enum class PushNotificationLogOutReason { | ||
| @SerialName("0") | ||
| KDF_CHANGE, | ||
| } | ||
|
|
||
| @Keep | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Good use of |
||
| private class PushNotificationLogOutReasonSerializer : | ||
| BaseEnumeratedIntSerializer<PushNotificationLogOutReason>( | ||
| className = "PushNotificationLogOutReason", | ||
| values = PushNotificationLogOutReason.entries.toTypedArray(), | ||
| ) | ||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Good use of |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -975,7 +975,7 @@ private val LOGOUT_KDF_NOTIFICATION_MAP = mapOf( | |
| "payload" to """{ | ||
| "UserId": "078966a2-93c2-4618-ae2a-0a2394c88d37", | ||
| "Date": "2023-10-27T12:00:00.000Z", | ||
| "PushNotificationLogOutReason": "0" | ||
| "Reason": 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Excellent fix! The test data has been properly updated to match the new field name and format:
This aligns with how other serialized enums work in the codebase (e.g., |
||
| }""", | ||
| ) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field name change from
"PushNotificationLogOutReason"to"Reason"breaks existing test data. The test filePushManagerTest.ktat line 978 still uses the old field name:Action Required: Update the test payload to use
"Reason": "0"to match the new serialization field name. This will cause deserialization to fail in tests otherwise.๐ Note: The
@JsonNamesannotation includes both"Reason"and"reason"(lowercase), which is good for backward compatibility with different casing from the backend. However, the old field name"PushNotificationLogOutReason"is completely different and won't be recognized.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update all the test JSON to reflect these changes