From d3e895eac6fadbdfa80bc2c8af0357cd4336b880 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 10:58:57 +1000 Subject: [PATCH] Don't append short IDs to display names --- .../loki/protocol/SessionMetaProtocol.kt | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt index a7acaa25fe..9f9a38427d 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt @@ -10,7 +10,6 @@ import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.messages.SignalServiceContent import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage -import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.security.MessageDigest object SessionMetaProtocol { @@ -37,24 +36,16 @@ object SessionMetaProtocol { @JvmStatic fun handleProfileUpdateIfNeeded(context: Context, content: SignalServiceContent) { - val rawDisplayName = content.senderDisplayName.orNull() ?: return - if (rawDisplayName.isBlank()) { return } + val displayName = content.senderDisplayName.orNull() ?: return + if (displayName.isBlank()) { return } val userPublicKey = TextSecurePreferences.getLocalNumber(context) val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context) val sender = content.sender.toLowerCase() if (userMasterPublicKey == sender) { // Update the user's local name if the message came from their master device - TextSecurePreferences.setProfileName(context, rawDisplayName) - } - // Don't overwrite if the message came from a linked device; the device name is - // stored as a user name - val allUserDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey) - if (!allUserDevices.contains(sender)) { - val displayName = rawDisplayName + " (..." + sender.substring(sender.length - 8) + ")" - DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName) - } else { - DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, rawDisplayName) + TextSecurePreferences.setProfileName(context, displayName) } + DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName) } @JvmStatic