mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Handle unregistered responses in more locations.
There were some send jobs where we knew users were unregistered, but we weren't marking them as such in the DB.
This commit is contained in:
committed by
Alex Hart
parent
125c4f43cf
commit
90c9cc17b9
@@ -20,9 +20,10 @@ final class GroupSendJobHelper {
|
||||
}
|
||||
|
||||
static @NonNull SendResult getCompletedSends(@NonNull List<Recipient> possibleRecipients, @NonNull Collection<SendMessageResult> results) {
|
||||
RecipientAccessList accessList = new RecipientAccessList(possibleRecipients);
|
||||
List<Recipient> completions = new ArrayList<>(results.size());
|
||||
List<RecipientId> skipped = new ArrayList<>();
|
||||
RecipientAccessList accessList = new RecipientAccessList(possibleRecipients);
|
||||
List<Recipient> completions = new ArrayList<>(results.size());
|
||||
List<RecipientId> skipped = new ArrayList<>();
|
||||
List<RecipientId> unregistered = new ArrayList<>();
|
||||
|
||||
for (SendMessageResult sendMessageResult : results) {
|
||||
Recipient recipient = accessList.requireByAddress(sendMessageResult.getAddress());
|
||||
@@ -34,6 +35,7 @@ final class GroupSendJobHelper {
|
||||
if (sendMessageResult.isUnregisteredFailure()) {
|
||||
Log.w(TAG, "Unregistered failure for " + recipient.getId());
|
||||
skipped.add(recipient.getId());
|
||||
unregistered.add(recipient.getId());
|
||||
}
|
||||
|
||||
if (sendMessageResult.getProofRequiredFailure() != null) {
|
||||
@@ -50,16 +52,23 @@ final class GroupSendJobHelper {
|
||||
}
|
||||
}
|
||||
|
||||
return new SendResult(completions, skipped);
|
||||
return new SendResult(completions, skipped, unregistered);
|
||||
}
|
||||
|
||||
public static class SendResult {
|
||||
/** Recipients that do not need to be sent to again. Includes certain types of non-retryable failures. Important: items in this list can overlap with other lists in the result. */
|
||||
public final List<Recipient> completed;
|
||||
|
||||
/** Recipients that were not sent to and can be shown as "skipped" in the UI. Important: items in this list can overlap with other lists in the result. */
|
||||
public final List<RecipientId> skipped;
|
||||
|
||||
public SendResult(@NonNull List<Recipient> completed, @NonNull List<RecipientId> skipped) {
|
||||
this.completed = completed;
|
||||
this.skipped = skipped;
|
||||
/** Recipients that were discovered to be unregistered. Important: items in this list can overlap with other lists in the result. */
|
||||
public final List<RecipientId> unregistered;
|
||||
|
||||
public SendResult(@NonNull List<Recipient> completed, @NonNull List<RecipientId> skipped, @NonNull List<RecipientId> unregistered) {
|
||||
this.completed = completed;
|
||||
this.skipped = skipped;
|
||||
this.unregistered = unregistered;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,13 @@ public class ProfileKeySendJob extends BaseJob {
|
||||
|
||||
List<SendMessageResult> results = GroupSendUtil.sendUnresendableDataMessage(context, null, destinations, false, ContentHint.IMPLICIT, dataMessage.build(), false);
|
||||
|
||||
return GroupSendJobHelper.getCompletedSends(destinations, results).completed;
|
||||
GroupSendJobHelper.SendResult groupResult = GroupSendJobHelper.getCompletedSends(destinations, results);
|
||||
|
||||
for (RecipientId unregistered : groupResult.unregistered) {
|
||||
SignalDatabase.recipients().markUnregistered(unregistered);
|
||||
}
|
||||
|
||||
return groupResult.completed;
|
||||
}
|
||||
|
||||
public static class Factory implements Job.Factory<ProfileKeySendJob> {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.jobmanager.JsonJobData;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
@@ -178,7 +179,13 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
|
||||
|
||||
List<SendMessageResult> results = GroupSendUtil.sendUnresendableDataMessage(context, groupId, destinations, false, ContentHint.IMPLICIT, groupDataMessage, false);
|
||||
|
||||
return GroupSendJobHelper.getCompletedSends(destinations, results).completed;
|
||||
GroupSendJobHelper.SendResult groupResult = GroupSendJobHelper.getCompletedSends(destinations, results);
|
||||
|
||||
for (RecipientId unregistered : groupResult.unregistered) {
|
||||
SignalDatabase.recipients().markUnregistered(unregistered);
|
||||
}
|
||||
|
||||
return groupResult.completed;
|
||||
}
|
||||
|
||||
public static class Factory implements Job.Factory<PushGroupSilentUpdateSendJob> {
|
||||
|
||||
@@ -243,7 +243,13 @@ public class ReactionSendJob extends BaseJob {
|
||||
results.add(ApplicationDependencies.getSignalServiceMessageSender().sendSyncMessage(dataMessage));
|
||||
}
|
||||
|
||||
return GroupSendJobHelper.getCompletedSends(destinations, results).completed;
|
||||
GroupSendJobHelper.SendResult groupResult = GroupSendJobHelper.getCompletedSends(destinations, results);
|
||||
|
||||
for (RecipientId unregistered : groupResult.unregistered) {
|
||||
SignalDatabase.recipients().markUnregistered(unregistered);
|
||||
}
|
||||
|
||||
return groupResult.completed;
|
||||
}
|
||||
|
||||
private static SignalServiceDataMessage.Reaction buildReaction(@NonNull Context context,
|
||||
|
||||
@@ -159,6 +159,10 @@ public class RemoteDeleteSendJob extends BaseJob {
|
||||
recipients.remove(completion.getId());
|
||||
}
|
||||
|
||||
for (RecipientId unregistered : sendResult.unregistered) {
|
||||
SignalDatabase.recipients().markUnregistered(unregistered);
|
||||
}
|
||||
|
||||
for (RecipientId skip : skipped) {
|
||||
recipients.remove(skip);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user