Improve handling of inbound UD messages.

This commit is contained in:
Greyson Parrelli
2022-01-21 12:51:22 -05:00
committed by GitHub
parent bfdedd57d1
commit b5dcf8e8f1
13 changed files with 60 additions and 28 deletions

View File

@@ -65,16 +65,17 @@ public class ProfileKeySendJob extends BaseJob {
if (queueLimits) {
return new ProfileKeySendJob(new Parameters.Builder()
.setQueue(conversationRecipient.getId().toQueueKey())
.setQueue("ProfileKeySendJob_" + conversationRecipient.getId().toQueueKey())
.setMaxInstancesForQueue(1)
.addConstraint(NetworkConstraint.KEY)
.addConstraint(DecryptionsDrainedConstraint.KEY)
.setLifespan(TimeUnit.DAYS.toMillis(1))
.setMaxAttempts(Parameters.UNLIMITED)
.build(), threadId, recipients);
} else {
return new ProfileKeySendJob(new Parameters.Builder()
.setQueue("ProfileKeySendJob_" + conversationRecipient.getId().toQueueKey())
.setQueue(conversationRecipient.getId().toQueueKey())
.addConstraint(NetworkConstraint.KEY)
.addConstraint(DecryptionsDrainedConstraint.KEY)
.setLifespan(TimeUnit.DAYS.toMillis(1))
.setMaxAttempts(Parameters.UNLIMITED)
.build(), threadId, recipients);

View File

@@ -285,7 +285,8 @@ public final class MessageContentProcessor {
.enqueue();
} else if (!threadRecipient.isGroup()) {
Log.i(TAG, "Message was to a 1:1. Ensuring this user has our profile key.");
ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob(false))
ApplicationDependencies.getJobManager()
.startChain(new RefreshAttributesJob(false))
.then(ProfileKeySendJob.create(context, SignalDatabase.threads().getOrCreateThreadIdFor(threadRecipient), true))
.enqueue();
}
@@ -1722,13 +1723,12 @@ public final class MessageContentProcessor {
@NonNull byte[] messageProfileKeyBytes,
@NonNull Recipient senderRecipient)
{
log(content.getTimestamp(), "Profile key.");
RecipientDatabase database = SignalDatabase.recipients();
ProfileKey messageProfileKey = ProfileKeyUtil.profileKeyOrNull(messageProfileKeyBytes);
if (messageProfileKey != null) {
if (database.setProfileKey(senderRecipient.getId(), messageProfileKey)) {
log(content.getTimestamp(), "Profile key on message from " + senderRecipient.getId() + " didn't match our local store. It has been updated.");
ApplicationDependencies.getJobManager().add(RetrieveProfileJob.forRecipient(senderRecipient.getId()));
}
} else {