Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
[UP] Display MayHaveMessagesNotification on push with locked db
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Jan 22, 2024
1 parent fe029db commit af174a7
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit af174a7

Please sign in to comment.