From 1d2679a128c18a45230a4babb6a0a6043fe4188e Mon Sep 17 00:00:00 2001 From: sim Date: Thu, 16 Nov 2023 23:25:29 +0100 Subject: [PATCH] Display MayHaveMessagesNotification on push with locked db for unifiedpush --- .../unifiedpush/receiver/UnifiedPushReceiver.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt b/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt index bb5b2555e3..5ea99c3e17 100644 --- a/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt +++ b/app/src/unifiedpush/java/im/molly/unifiedpush/receiver/UnifiedPushReceiver.kt @@ -9,8 +9,11 @@ import im.molly.unifiedpush.util.UnifiedPushNotificationBuilder import org.signal.core.util.concurrent.SignalExecutors import org.signal.core.util.logging.Log import org.thoughtcrime.securesms.dependencies.ApplicationDependencies +import org.thoughtcrime.securesms.gcm.FcmFetchManager import org.thoughtcrime.securesms.gcm.FcmReceiveService import org.thoughtcrime.securesms.keyvalue.SignalStore +import org.thoughtcrime.securesms.service.KeyCachingService +import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor import org.unifiedpush.android.connector.MessagingReceiver @@ -39,6 +42,16 @@ class UnifiedPushReceiver : MessagingReceiver() { } override fun onMessage(context: Context, message: ByteArray, instance: String) { + if (KeyCachingService.isLocked()) { + // We look directly in the message to avoid its deserialization + if (message.toString(Charsets.UTF_8).contains("\"urgent\":true") && + TextSecurePreferences.isPassphraseLockNotificationsEnabled(context)) { + Log.d(TAG, "New urgent message received while app is locked.") + FcmFetchManager.postMayHaveMessagesNotification(context) + } + return + } + if (SignalStore.account().isRegistered && UnifiedPushHelper.isUnifiedPushAvailable()) { Log.d(TAG, "New message") EXECUTOR.enqueue {