TF-2298 Update expires time when old token has expired

Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit fb26afe8f52df6e16476aea8a68f9f92c5c4b001)
This commit is contained in:
dab246
2023-12-04 10:53:26 +07:00
committed by Dat H. Pham
parent e3dea129b6
commit f5d878012d
72 changed files with 964 additions and 736 deletions
@@ -1,10 +0,0 @@
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_subscription.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/fcm_subscription.dart';
extension FCMSubscriptionExtension on FCMSubscription {
FCMSubscriptionCache toFCMSubscriptionCache() {
return FCMSubscriptionCache(deviceId, subscriptionId);
}
}
@@ -0,0 +1,20 @@
import 'package:fcm/converter/device_client_id_nullable_converter.dart';
import 'package:fcm/converter/fcm_token_nullable_converter.dart';
import 'package:fcm/converter/firebase_registration_id_nullable_converter.dart';
import 'package:fcm/converter/type_name_converter.dart';
import 'package:fcm/model/firebase_registration.dart';
import 'package:fcm/model/firebase_registration_expired_time.dart';
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_registration_cache.dart';
extension FirebaseRegistrationCacheExtension on FirebaseRegistrationCache {
FirebaseRegistration toFirebaseRegistration() {
return FirebaseRegistration(
id: const FirebaseRegistrationIdNullableConverter().fromJson(id),
token: const FcmTokenNullableConverter().fromJson(token),
deviceClientId: const DeviceClientIdNullableConverter().fromJson(deviceClientId),
expires: expires != null ? FirebaseRegistrationExpiredTime(UTCDate(expires!)) : null,
types: types?.map((type) => const TypeNameConverter().fromJson(type)).toList()
);
}
}
@@ -0,0 +1,14 @@
import 'package:fcm/model/firebase_registration.dart';
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_registration_cache.dart';
extension FirebaseRegistrationExtension on FirebaseRegistration {
FirebaseRegistrationCache toFirebaseRegistrationCache() {
return FirebaseRegistrationCache(
deviceClientId: deviceClientId!.value,
id: id?.id.value,
token: token?.value,
expires: expires?.value.value,
types: types?.map((type) => type.value).toList(),
);
}
}