Page MenuHomePhabricator

D4237.id13603.diff
No OneTemporary

D4237.id13603.diff

diff --git a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
@@ -4,9 +4,13 @@
import android.content.Context;
import android.service.notification.StatusBarNotification;
import android.util.Log;
+import app.comm.android.fbjni.CommSecureStore;
import app.comm.android.fbjni.NetworkModule;
+import app.comm.android.fbjni.ThreadOperations;
import com.google.firebase.messaging.RemoteMessage;
+import expo.modules.securestore.SecureStoreModule;
import io.invertase.firebase.messaging.RNFirebaseMessagingService;
+import java.io.File;
import me.leolin.shortcutbadger.ShortcutBadger;
/**
@@ -40,11 +44,15 @@
private static final String BADGE_KEY = "badge";
private static final String BADGE_ONLY_KEY = "badgeOnly";
private static final String BACKGROUND_NOTIF_TYPE_KEY = "backgroundNotifType";
+ private static final String THREAD_ID_KEY = "threadID";
+ private static final String SET_UNREAD_STATUS_KEY = "setUnreadStatus";
private NotificationManager notificationManager;
@Override
public void onCreate() {
super.onCreate();
+ CommSecureStore.getInstance().initialize(
+ () -> new SecureStoreModule(this.getApplicationContext()));
notificationManager = (NotificationManager)this.getSystemService(
Context.NOTIFICATION_SERVICE);
}
@@ -52,16 +60,9 @@
@Override
public void onMessageReceived(RemoteMessage message) {
String rescind = message.getData().get(RESCIND_KEY);
- String rescindID = message.getData().get(RESCIND_ID_KEY);
if ("true".equals(rescind) &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- for (StatusBarNotification notification :
- notificationManager.getActiveNotifications()) {
- if (notification.getTag().equals(rescindID)) {
- notificationManager.cancel(
- notification.getTag(), notification.getId());
- }
- }
+ handleNotificationRescind(message);
}
String badge = message.getData().get(BADGE_KEY);
@@ -92,4 +93,28 @@
super.onMessageReceived(message);
}
+
+ private void handleNotificationRescind(RemoteMessage message) {
+ String setUnreadStatus = message.getData().get(SET_UNREAD_STATUS_KEY);
+ if ("true".equals(setUnreadStatus)) {
+ File sqliteFile =
+ this.getApplicationContext().getDatabasePath("comm.sqlite");
+ if (sqliteFile.exists()) {
+ String threadID = message.getData().get(THREAD_ID_KEY);
+ ThreadOperations.updateSQLiteUnreadStatus(
+ sqliteFile.getPath(), threadID, false);
+ } else {
+ Log.w(
+ "COMM",
+ "Database not existing yet. Skipping thread status update.");
+ }
+ }
+ String rescindID = message.getData().get(RESCIND_ID_KEY);
+ for (StatusBarNotification notification :
+ notificationManager.getActiveNotifications()) {
+ if (notification.getTag().equals(rescindID)) {
+ notificationManager.cancel(notification.getTag(), notification.getId());
+ }
+ }
+ }
}

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 8:53 PM (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594601
Default Alt Text
D4237.id13603.diff (3 KB)

Event Timeline