Update notification on profile name fetch or change.

This commit is contained in:
Clark
2023-04-06 11:46:55 -04:00
committed by Greyson Parrelli
parent 71e2b8225a
commit 27e3c883c3

View File

@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.notifications.v2.ConversationId;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@@ -462,12 +463,12 @@ public class RetrieveProfileJob extends BaseJob {
String remoteDisplayName = remoteProfileName.toString();
String localDisplayName = localProfileName.toString();
if (!recipient.isBlocked() &&
!recipient.isGroup() &&
!recipient.isSelf() &&
!localDisplayName.isEmpty() &&
!remoteDisplayName.equals(localDisplayName))
{
boolean writeChangeEvent = !recipient.isBlocked() &&
!recipient.isGroup() &&
!recipient.isSelf() &&
!localDisplayName.isEmpty() &&
!remoteDisplayName.equals(localDisplayName);
if (writeChangeEvent) {
Log.i(TAG, "Writing a profile name change event for " + recipient.getId());
SignalDatabase.messages().insertProfileNameChangeMessages(recipient, remoteDisplayName, localDisplayName);
} else {
@@ -475,6 +476,13 @@ public class RetrieveProfileJob extends BaseJob {
recipient.isBlocked(), recipient.isGroup(), recipient.isSelf(), localDisplayName.isEmpty(), !remoteDisplayName.equals(localDisplayName)));
}
if (writeChangeEvent || localDisplayName.isEmpty()) {
Long threadId = SignalDatabase.threads().getThreadIdFor(recipient.getId());
if (threadId != null) {
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(threadId));
}
}
return true;
}
} catch (InvalidCiphertextException e) {