mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 03:08:50 +03:00
Update NotificationPayload to handle null values (#3391)
This commit is contained in:
parent
44e2596a30
commit
f5039d72b9
2 changed files with 18 additions and 6 deletions
|
@ -153,7 +153,14 @@ class PushManagerImpl @Inject constructor(
|
|||
-> {
|
||||
val payload: NotificationPayload.SyncCipherNotification =
|
||||
json.decodeFromString(notification.payload)
|
||||
if (!isLoggedIn(userId) || !payload.userMatchesNotification(userId)) return
|
||||
@Suppress("ComplexCondition")
|
||||
if (payload.id == null ||
|
||||
payload.revisionDate == null ||
|
||||
!isLoggedIn(userId) ||
|
||||
!payload.userMatchesNotification(userId)
|
||||
) {
|
||||
return
|
||||
}
|
||||
mutableSyncCipherUpsertSharedFlow.tryEmit(
|
||||
SyncCipherUpsertData(
|
||||
cipherId = payload.id,
|
||||
|
@ -170,7 +177,12 @@ class PushManagerImpl @Inject constructor(
|
|||
-> {
|
||||
val payload: NotificationPayload.SyncCipherNotification =
|
||||
json.decodeFromString(notification.payload)
|
||||
if (!isLoggedIn(userId) || !payload.userMatchesNotification(userId)) return
|
||||
if (payload.id == null ||
|
||||
!isLoggedIn(userId) ||
|
||||
!payload.userMatchesNotification(userId)
|
||||
) {
|
||||
return
|
||||
}
|
||||
mutableSyncCipherDeleteSharedFlow.tryEmit(
|
||||
SyncCipherDeleteData(payload.id),
|
||||
)
|
||||
|
@ -291,8 +303,8 @@ class PushManagerImpl @Inject constructor(
|
|||
.fold(
|
||||
onSuccess = {
|
||||
pushDiskSource.storeLastPushTokenRegistrationDate(
|
||||
userId,
|
||||
ZonedDateTime.ofInstant(clock.instant(), ZoneOffset.UTC),
|
||||
userId = userId,
|
||||
registrationDate = ZonedDateTime.ofInstant(clock.instant(), ZoneOffset.UTC),
|
||||
)
|
||||
pushDiskSource.storeCurrentPushToken(
|
||||
userId = userId,
|
||||
|
|
|
@ -20,12 +20,12 @@ sealed class NotificationPayload {
|
|||
*/
|
||||
@Serializable
|
||||
data class SyncCipherNotification(
|
||||
@SerialName("Id") val id: String,
|
||||
@SerialName("Id") val id: String?,
|
||||
@SerialName("UserId") override val userId: String?,
|
||||
@SerialName("OrganizationId") val organizationId: String?,
|
||||
@SerialName("CollectionIds") val collectionIds: List<String>?,
|
||||
@Contextual
|
||||
@SerialName("RevisionDate") val revisionDate: ZonedDateTime,
|
||||
@SerialName("RevisionDate") val revisionDate: ZonedDateTime?,
|
||||
) : NotificationPayload()
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue