Merge pull request #378 from RyanRory/PN-fix-database

Push Notification Fixes Part 2
This commit is contained in:
Niels Andriesse 2020-11-13 10:52:39 +11:00 committed by GitHub
commit 7ed9d984b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 36 deletions

View File

@ -61,36 +61,36 @@ import network.loki.messenger.R;
public class DatabaseUpgradeActivity extends BaseActivity { public class DatabaseUpgradeActivity extends BaseActivity {
private static final String TAG = DatabaseUpgradeActivity.class.getSimpleName(); private static final String TAG = DatabaseUpgradeActivity.class.getSimpleName();
public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 46; public static final int NO_MORE_KEY_EXCHANGE_PREFIX_VERSION = 0; // 46
public static final int MMS_BODY_VERSION = 46; public static final int MMS_BODY_VERSION = 0; // 46
public static final int TOFU_IDENTITIES_VERSION = 50; public static final int TOFU_IDENTITIES_VERSION = 1; // 50
public static final int CURVE25519_VERSION = 63; public static final int CURVE25519_VERSION = 2; // 63
public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 73; public static final int ASYMMETRIC_MASTER_SECRET_FIX_VERSION = 3; // 73
public static final int NO_V1_VERSION = 83; public static final int NO_V1_VERSION = 4; // 83
public static final int SIGNED_PREKEY_VERSION = 83; public static final int SIGNED_PREKEY_VERSION = 4; // 83
public static final int NO_DECRYPT_QUEUE_VERSION = 113; public static final int NO_DECRYPT_QUEUE_VERSION = 5; // 113
public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 131; public static final int PUSH_DECRYPT_SERIAL_ID_VERSION = 6; // 131
public static final int MIGRATE_SESSION_PLAINTEXT = 136; public static final int MIGRATE_SESSION_PLAINTEXT = 7; // 136
public static final int CONTACTS_ACCOUNT_VERSION = 136; public static final int CONTACTS_ACCOUNT_VERSION = 7; // 136
public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 151; public static final int MEDIA_DOWNLOAD_CONTROLS_VERSION = 8; // 151
public static final int REDPHONE_SUPPORT_VERSION = 157; public static final int REDPHONE_SUPPORT_VERSION = 9; // 157
public static final int NO_MORE_CANONICAL_DB_VERSION = 276; public static final int NO_MORE_CANONICAL_DB_VERSION = 10; // 276
public static final int PROFILES = 289; public static final int PROFILES = 11; // 289
public static final int SCREENSHOTS = 300; public static final int SCREENSHOTS = 12; // 300
public static final int PERSISTENT_BLOBS = 317; public static final int PERSISTENT_BLOBS = 13; // 317
public static final int INTERNALIZE_CONTACTS = 317; public static final int INTERNALIZE_CONTACTS = 13; // 317
public static final int SQLCIPHER = 334; public static final int SQLCIPHER = 14; // 334
public static final int SQLCIPHER_COMPLETE = 352; public static final int SQLCIPHER_COMPLETE = 15; // 352
public static final int REMOVE_JOURNAL = 353; public static final int REMOVE_JOURNAL = 16; // 353
public static final int REMOVE_CACHE = 354; public static final int REMOVE_CACHE = 17; // 354
public static final int FULL_TEXT_SEARCH = 358; public static final int FULL_TEXT_SEARCH = 18; // 358
public static final int BAD_IMPORT_CLEANUP = 373; public static final int BAD_IMPORT_CLEANUP = 19; // 373
public static final int IMAGE_CACHE_CLEANUP = 406; public static final int IMAGE_CACHE_CLEANUP = 20; // 406
public static final int WORKMANAGER_MIGRATION = 408; public static final int WORKMANAGER_MIGRATION = 21; // 408
public static final int COLOR_MIGRATION = 412; public static final int COLOR_MIGRATION = 22; // 412
public static final int UNIDENTIFIED_DELIVERY = 422; public static final int UNIDENTIFIED_DELIVERY = 23; // 422
public static final int SIGNALING_KEY_DEPRECATION = 447; public static final int SIGNALING_KEY_DEPRECATION = 24; // 447
public static final int CONVERSATION_SEARCH = 455; public static final int CONVERSATION_SEARCH = 25; // 455
private static final SortedSet<Integer> UPGRADE_VERSIONS = new TreeSet<Integer>() {{ private static final SortedSet<Integer> UPGRADE_VERSIONS = new TreeSet<Integer>() {{
add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION); add(NO_MORE_KEY_EXCHANGE_PREFIX_VERSION);

View File

@ -1,14 +1,11 @@
package org.thoughtcrime.securesms.loki.api package org.thoughtcrime.securesms.loki.api
import android.R import androidx.core.app.NotificationCompat
import android.app.NotificationManager import androidx.core.app.NotificationManagerCompat
import android.app.PendingIntent
import android.content.Intent
import android.graphics.Color
import android.media.RingtoneManager
import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage import com.google.firebase.messaging.RemoteMessage
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob import org.thoughtcrime.securesms.jobs.PushContentReceiveJob
import org.thoughtcrime.securesms.notifications.NotificationChannels
import org.thoughtcrime.securesms.util.TextSecurePreferences import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.libsignal.logging.Log import org.whispersystems.libsignal.logging.Log
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope
@ -37,6 +34,24 @@ class PushNotificationService : FirebaseMessagingService() {
} }
} else { } else {
Log.d("Loki", "Failed to decode data for message.") Log.d("Loki", "Failed to decode data for message.")
val builder = NotificationCompat.Builder(this, NotificationChannels.OTHER)
.setSmallIcon(network.loki.messenger.R.drawable.ic_notification)
.setColor(this.getResources().getColor(network.loki.messenger.R.color.textsecure_primary))
.setContentTitle("Session")
.setContentText("You've got a new message.")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true)
with(NotificationManagerCompat.from(this)) {
notify(11111, builder.build())
} }
} }
}
override fun onDeletedMessages() {
org.thoughtcrime.securesms.logging.Log.d("Loki", "Called onDeletedMessages.")
super.onDeletedMessages()
val token = TextSecurePreferences.getFCMToken(this)
val userPublicKey = TextSecurePreferences.getLocalNumber(this) ?: return
LokiPushNotificationManager.register(token, userPublicKey, this, true)
}
} }