From 67eee3ddeae212a760bfc5415c8a3e2d72007cf2 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 22 Jan 2020 13:43:18 +1100 Subject: [PATCH] Fix notification display name --- .../SingleRecipientNotificationBuilder.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index ecef23b0d8..4c20a22926 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactColors; import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto; import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto; import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto; +import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader; import org.thoughtcrime.securesms.mms.GlideApp; @@ -38,6 +39,7 @@ import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; +import org.whispersystems.signalservice.loki.api.LokiPublicChat; import java.util.LinkedList; import java.util.List; @@ -118,7 +120,16 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); if (privacy.isDisplayContact() && threadRecipients.isGroupRecipient()) { - stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": ")); + long threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(threadRecipients); + LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID); + String hexEncodedPublicKey = individualRecipient.getAddress().toString(); + String displayName; + if (publicChat != null) { + displayName = DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChat.getId(), hexEncodedPublicKey); + } else { + displayName = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(hexEncodedPublicKey); + } + stringBuilder.append(Util.getBoldedString(displayName + ": ")); } if (privacy.isDisplayMessage()) {