kopia lustrzana https://github.com/ryukoposting/Signal-Android
Prevent insertion of UUID-only contacts at the database level.
rodzic
f8f959e05a
commit
23401440bf
|
@ -32,6 +32,7 @@ import org.thoughtcrime.securesms.storage.StorageSyncHelper;
|
|||
import org.thoughtcrime.securesms.storage.StorageSyncHelper.RecordUpdate;
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncModels;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||
import org.thoughtcrime.securesms.util.SqlUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
@ -491,7 +492,7 @@ public class RecipientDatabase extends Database {
|
|||
try {
|
||||
|
||||
for (SignalContactRecord insert : contactInserts) {
|
||||
ContentValues values = getValuesForStorageContact(insert);
|
||||
ContentValues values = validateContactValuesForInsert(getValuesForStorageContact(insert));
|
||||
long id = db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
|
||||
|
||||
if (id < 0) {
|
||||
|
@ -1644,6 +1645,17 @@ public class RecipientDatabase extends Database {
|
|||
}
|
||||
}
|
||||
|
||||
private static ContentValues validateContactValuesForInsert(ContentValues values) {
|
||||
if (!FeatureFlags.uuids() &&
|
||||
values.getAsString(UUID) != null &&
|
||||
values.getAsString(PHONE) == null)
|
||||
{
|
||||
throw new UuidRecipientError();
|
||||
} else {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
public class BulkOperationsHandle {
|
||||
|
||||
private final SQLiteDatabase database;
|
||||
|
@ -2041,4 +2053,7 @@ public class RecipientDatabase extends Database {
|
|||
this.neededInsert = neededInsert;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UuidRecipientError extends AssertionError {
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue