Skip to content

Commit 0959284

Browse files
authored
[PM-26736] Fix push notification logout reason serialization (#6116)
1 parent 1f24ca7 commit 0959284

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/model/NotificationPayload.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sealed class NotificationPayload {
5757
@JsonNames("Date", "date")
5858
val date: ZonedDateTime?,
5959

60-
@JsonNames("PushNotificationLogOutReason", "pushNotificationLogOutReason")
60+
@JsonNames("Reason", "reason")
6161
val pushNotificationLogOutReason: PushNotificationLogOutReason?,
6262
) : NotificationPayload()
6363

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
package com.x8bit.bitwarden.data.platform.manager.model
22

3+
import androidx.annotation.Keep
4+
import com.bitwarden.core.data.serializer.BaseEnumeratedIntSerializer
35
import kotlinx.serialization.SerialName
6+
import kotlinx.serialization.Serializable
47

58
/**
69
* Enumerated values to represent the possible reasons for a log out push notification
710
*/
11+
@Serializable(with = PushNotificationLogOutReasonSerializer::class)
812
enum class PushNotificationLogOutReason {
913
@SerialName("0")
1014
KDF_CHANGE,
1115
}
16+
17+
@Keep
18+
private class PushNotificationLogOutReasonSerializer :
19+
BaseEnumeratedIntSerializer<PushNotificationLogOutReason>(
20+
className = "PushNotificationLogOutReason",
21+
values = PushNotificationLogOutReason.entries.toTypedArray(),
22+
)

app/src/test/kotlin/com/x8bit/bitwarden/data/platform/manager/PushManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ private val LOGOUT_KDF_NOTIFICATION_MAP = mapOf(
975975
"payload" to """{
976976
"UserId": "078966a2-93c2-4618-ae2a-0a2394c88d37",
977977
"Date": "2023-10-27T12:00:00.000Z",
978-
"PushNotificationLogOutReason": "0"
978+
"Reason": 0
979979
}""",
980980
)
981981

0 commit comments

Comments
 (0)