Retrieve profiles on mismatch to notify user of updates quicker.

This commit is contained in:
Cody Henthorne 2020-06-26 11:24:32 -04:00 committed by Alan Evans
parent 0364bec995
commit 31b995fa98
4 changed files with 23 additions and 2 deletions

View file

@ -232,6 +232,9 @@ public class PushGroupSendJob extends PushSendJob {
} else if (!identityMismatches.isEmpty()) {
database.markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId);
List<RecipientId> mismatchRecipientIds = Stream.of(identityMismatches).map(mismatch -> mismatch.getRecipientId(context)).toList();
RetrieveProfileJob.enqueue(mismatchRecipientIds);
}
} catch (UntrustedIdentityException | UndeliverableMessageException e) {
warn(TAG, e);

View file

@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
@ -165,8 +166,10 @@ public class PushMediaSendJob extends PushSendJob {
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(false));
} catch (UntrustedIdentityException uie) {
warn(TAG, "Failure", uie);
database.addMismatchedIdentity(messageId, Recipient.external(context, uie.getIdentifier()).getId(), uie.getIdentityKey());
RecipientId recipientId = Recipient.external(context, uie.getIdentifier()).getId();
database.addMismatchedIdentity(messageId, recipientId, uie.getIdentityKey());
database.markAsSentFailed(messageId);
RetrieveProfileJob.enqueue(recipientId);
}
}

View file

@ -14,7 +14,9 @@ import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
@ -122,9 +124,11 @@ public class PushTextSendJob extends PushSendJob {
ApplicationDependencies.getJobManager().add(new DirectoryRefreshJob(false));
} catch (UntrustedIdentityException e) {
warn(TAG, "Failure", e);
database.addMismatchedIdentity(record.getId(), Recipient.external(context, e.getIdentifier()).getId(), e.getIdentityKey());
RecipientId recipientId = Recipient.external(context, e.getIdentifier()).getId();
database.addMismatchedIdentity(record.getId(), recipientId, e.getIdentityKey());
database.markAsSentFailed(record.getId());
database.markAsPush(record.getId());
RetrieveProfileJob.enqueue(recipientId);
}
}

View file

@ -84,6 +84,17 @@ public class RetrieveProfileJob extends BaseJob {
});
}
/**
* Submits the necessary job to refresh the profile of the requested recipient. Works for any
* RecipientId, including individuals, groups, or yourself.
*
* Identical to {@link #enqueue(Collection)})}
*/
@WorkerThread
public static void enqueue(@NonNull RecipientId recipientId) {
ApplicationDependencies.getJobManager().add(forRecipient(recipientId));
}
/**
* Submits the necessary jobs to refresh the profiles of the requested recipients. Works for any
* RecipientIds, including individuals, groups, or yourself.