fix: bundled notification no longer notifies on mentions only

This commit is contained in:
Harris 2021-08-19 12:14:21 +10:00
parent 1f3db80d36
commit 975076cb5c
2 changed files with 18 additions and 2 deletions

View File

@ -315,7 +315,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
List<NotificationItem> notifications = notificationState.getNotifications();
Recipient recipient = notifications.get(0).getRecipient();
int notificationId = (int) (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getThreadId() : 0));
String messageIdTag = String.valueOf(notifications.get(0).getId());
String messageIdTag = String.valueOf(notifications.get(0).getTimestamp());
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
for (StatusBarNotification notification: notificationManager.getActiveNotifications()) {
@ -402,6 +402,16 @@ public class DefaultMessageNotifier implements MessageNotifier {
builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
builder.setAutoCancel(true);
String messageIdTag = String.valueOf(notifications.get(0).getTimestamp());
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
for (StatusBarNotification notification: notificationManager.getActiveNotifications()) {
if (notification.getId() == SUMMARY_NOTIFICATION_ID
&& messageIdTag.equals(notification.getNotification().extras.getString(LATEST_MESSAGE_ID_TAG))) {
return;
}
}
long timestamp = notifications.get(0).getTimestamp();
if (timestamp != 0) builder.setWhen(timestamp);
@ -421,6 +431,8 @@ public class DefaultMessageNotifier implements MessageNotifier {
MentionUtilities.highlightMentions(notifications.get(0).getText(), notifications.get(0).getThreadId(), context));
}
builder.putStringExtra(LATEST_MESSAGE_ID_TAG, messageIdTag);
Notification notification = builder.build();
NotificationManagerCompat.from(context).notify(SUMMARY_NOTIFICATION_ID, builder.build());
Log.i(TAG, "Posted notification. " + notification.toString());

View File

@ -16,8 +16,8 @@ import org.session.libsession.utilities.TextSecurePreferences;
import org.session.libsession.utilities.Util;
import org.session.libsession.utilities.recipients.Recipient;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.home.HomeActivity;
import org.thoughtcrime.securesms.database.SessionContactDatabase;
import org.thoughtcrime.securesms.home.HomeActivity;
import java.util.LinkedList;
import java.util.List;
@ -72,6 +72,10 @@ public class MultipleRecipientNotificationBuilder extends AbstractNotificationBu
extend(new NotificationCompat.WearableExtender().addAction(markAllAsReadAction));
}
public void putStringExtra(String key, String value) {
extras.putString(key,value);
}
public void addMessageBody(@NonNull Recipient sender, Recipient threadRecipient, @Nullable CharSequence body) {
String displayName = sender.toShortString();
if (threadRecipient.isOpenGroupRecipient()) {