From 11aed5daff8b9b2a54df32fdea9b06fbd75680c4 Mon Sep 17 00:00:00 2001 From: jubb Date: Tue, 27 Apr 2021 09:38:07 +1000 Subject: [PATCH] refactor: don't update profile if it is user's at all in visible message handling, leave it to config updates --- .../sending_receiving/MessageReceiverHandler.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageReceiverHandler.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageReceiverHandler.kt index cabb92b8c7..5781079830 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageReceiverHandler.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageReceiverHandler.kt @@ -148,17 +148,14 @@ private fun handleConfigurationMessage(message: ConfigurationMessage) { fun MessageReceiver.handleVisibleMessage(message: VisibleMessage, proto: SignalServiceProtos.Content, openGroupID: String?) { val storage = MessagingConfiguration.shared.storage val context = MessagingConfiguration.shared.context + val userPublicKey = storage.getUserPublicKey() // Update profile if needed val newProfile = message.profile - if (newProfile != null && openGroupID.isNullOrEmpty()) { + if (newProfile != null && openGroupID.isNullOrEmpty() && userPublicKey != message.sender) { val profileManager = SSKEnvironment.shared.profileManager val recipient = Recipient.from(context, Address.fromSerialized(message.sender!!), false) val displayName = newProfile.displayName!! - val userPublicKey = storage.getUserPublicKey() - if (userPublicKey == message.sender && displayName.isNotEmpty()) { - // Update the user's local name if the message came from their master device - TextSecurePreferences.setProfileName(context, displayName) - } else if (displayName.isNotEmpty()) { + if (displayName.isNotEmpty()) { profileManager.setDisplayName(context, recipient, displayName) } if (newProfile.profileKey?.isNotEmpty() == true && !MessageDigest.isEqual(recipient.profileKey, newProfile.profileKey)) {