feat: Implement deduplication for FCM token subscription and update related logic
This commit is contained in:
@@ -13,9 +13,7 @@ import com.rosetta.messenger.MainActivity
|
||||
import com.rosetta.messenger.R
|
||||
import com.rosetta.messenger.data.AccountManager
|
||||
import com.rosetta.messenger.data.PreferencesManager
|
||||
import com.rosetta.messenger.network.PacketPushNotification
|
||||
import com.rosetta.messenger.network.ProtocolManager
|
||||
import com.rosetta.messenger.network.PushNotificationAction
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
@@ -70,15 +68,9 @@ class RosettaFirebaseMessagingService : FirebaseMessagingService() {
|
||||
saveFcmToken(token)
|
||||
|
||||
// Best-effort: если соединение уже авторизовано — сразу обновляем подписку на push.
|
||||
// Используем единую точку отправки в ProtocolManager (с дедупликацией).
|
||||
if (ProtocolManager.isAuthenticated()) {
|
||||
runCatching {
|
||||
ProtocolManager.send(
|
||||
PacketPushNotification().apply {
|
||||
notificationsToken = token
|
||||
action = PushNotificationAction.SUBSCRIBE
|
||||
}
|
||||
)
|
||||
}
|
||||
runCatching { ProtocolManager.subscribePushTokenIfAvailable(forceToken = token) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user