mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-05 23:55:39 +00:00
Don't append short IDs to display names
This commit is contained in:
parent
5e86b253a8
commit
d3e895eac6
@ -10,7 +10,6 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
|||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
||||||
import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol
|
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
object SessionMetaProtocol {
|
object SessionMetaProtocol {
|
||||||
@ -37,24 +36,16 @@ object SessionMetaProtocol {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun handleProfileUpdateIfNeeded(context: Context, content: SignalServiceContent) {
|
fun handleProfileUpdateIfNeeded(context: Context, content: SignalServiceContent) {
|
||||||
val rawDisplayName = content.senderDisplayName.orNull() ?: return
|
val displayName = content.senderDisplayName.orNull() ?: return
|
||||||
if (rawDisplayName.isBlank()) { return }
|
if (displayName.isBlank()) { return }
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||||
val sender = content.sender.toLowerCase()
|
val sender = content.sender.toLowerCase()
|
||||||
if (userMasterPublicKey == sender) {
|
if (userMasterPublicKey == sender) {
|
||||||
// Update the user's local name if the message came from their master device
|
// Update the user's local name if the message came from their master device
|
||||||
TextSecurePreferences.setProfileName(context, rawDisplayName)
|
TextSecurePreferences.setProfileName(context, displayName)
|
||||||
}
|
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
|
DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user