mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-10 03:38:34 +00:00
Prevent insertion of UUID-only contacts at the database level.
This commit is contained in:
parent
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 {
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user