From dc40ff0548fe6b2f0eee8071c481f80cd6d0c744 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 20 Nov 2019 11:59:18 +1100 Subject: [PATCH] Only update display name from received message if the user is not one of our devices. --- .../thoughtcrime/securesms/jobs/PushDecryptJob.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 94a0095349..4c94ae0594 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -311,13 +311,17 @@ public class PushDecryptJob extends BaseJob implements InjectableType { // Loki - Store the sender display name if needed Optional rawSenderDisplayName = content.senderDisplayName; if (rawSenderDisplayName.isPresent() && rawSenderDisplayName.get().length() > 0) { - setDisplayName(envelope.getSource(), rawSenderDisplayName.get()); - - // If we got a name from our primary device then we also set that + // If we got a name from our primary device then we set our profile name to match it String ourPrimaryDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context); if (ourPrimaryDevice != null && envelope.getSource().equals(ourPrimaryDevice)) { TextSecurePreferences.setProfileName(context, rawSenderDisplayName.get()); } + + // If we receive a message from our device then don't set the display name in the database (as we probably have a alias set for them) + MultiDeviceUtilities.isOneOfOurDevices(context, Address.fromSerialized(content.getSender())).success(isOneOfOurDevice -> { + if (!isOneOfOurDevice) { setDisplayName(envelope.getSource(), rawSenderDisplayName.get()); } + return Unit.INSTANCE; + }); } // TODO: Deleting the display name