Prevent crash on clients with bad data.

fork-5.53.8
Cody Henthorne 2022-07-21 12:10:52 -04:00
rodzic 041bde3fd9
commit a845a020d6
1 zmienionych plików z 19 dodań i 1 usunięć

Wyświetl plik

@ -8,8 +8,12 @@ import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
import java.util.List;
import java.util.stream.Collectors;
/**
* Marks all distribution lists as needing to be synced with storage service.
*/
@ -48,7 +52,21 @@ public final class SyncDistributionListsMigrationJob extends MigrationJob {
Log.i(TAG, "Stories capability is not supported.");
}
SignalDatabase.recipients().markNeedsSync(SignalDatabase.distributionLists().getAllListRecipients());
List<RecipientId> listRecipients = SignalDatabase.distributionLists()
.getAllListRecipients()
.stream()
.filter(id -> {
try {
Recipient.resolved(id);
return true;
} catch (Exception e) {
Log.e(TAG, "Unable to resolve distribution list recipient: " + id, e);
return false;
}
})
.collect(Collectors.toList());
SignalDatabase.recipients().markNeedsSync(listRecipients);
StorageSyncHelper.scheduleSyncForDataChange();
}