Disallow marking users as registered without a UUID.

This commit is contained in:
Greyson Parrelli
2021-08-24 12:21:36 -04:00
committed by Alex Hart
parent 665d9e31f6
commit eb48ab1784
3 changed files with 6 additions and 19 deletions

View File

@@ -175,7 +175,7 @@ public class DirectoryHelper {
recipient = Recipient.resolved(recipientDatabase.getByUuid(uuid).get());
}
} else {
recipientDatabase.markRegistered(recipient.getId());
Log.w(TAG, "Registered number set had a null UUID!");
}
} else if (recipient.hasUuid() && recipient.isRegistered() && hasCommunicatedWith(context, recipient)) {
if (isUuidRegistered(context, recipient)) {

View File

@@ -1129,7 +1129,7 @@ public class RecipientDatabase extends Database {
*/
public @NonNull Map<RecipientId, StorageId> getContactStorageSyncIdsMap() {
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
String query = STORAGE_SERVICE_ID + " NOT NULL AND " + ID + " != ? AND " + GROUP_TYPE + " != ?";
String query = STORAGE_SERVICE_ID + " NOT NULL AND " + UUID + " NOT NULL AND " + ID + " != ? AND " + GROUP_TYPE + " != ?";
String[] args = SqlUtil.buildArgs(Recipient.self().getId(), String.valueOf(GroupType.SIGNAL_V2.getId()));
Map<RecipientId, StorageId> out = new HashMap<>();
@@ -2112,21 +2112,6 @@ public class RecipientDatabase extends Database {
}
}
/**
* Marks the user as registered without providing a UUID. This should only be used when one
* cannot be reasonably obtained. {@link #markRegistered(RecipientId, UUID)} should be strongly
* preferred.
*/
public void markRegistered(@NonNull RecipientId id) {
ContentValues contentValues = new ContentValues(1);
contentValues.put(REGISTERED, RegisteredState.REGISTERED.getId());
if (update(id, contentValues)) {
setStorageIdIfNotSet(id);
Recipient.live(id).refresh();
}
}
public void markUnregistered(@NonNull RecipientId id) {
ContentValues contentValues = new ContentValues(2);
contentValues.put(REGISTERED, RegisteredState.NOT_REGISTERED.getId());

View File

@@ -228,9 +228,11 @@ public class Recipient {
Recipient resolved = resolved(recipientId);
if (highTrust && !resolved.isRegistered()) {
if (highTrust && !resolved.isRegistered() && uuid != null) {
Log.w(TAG, "External high-trust push was locally marked unregistered. Marking as registered.");
db.markRegistered(recipientId);
db.markRegistered(recipientId, uuid);
} else if (highTrust && !resolved.isRegistered()) {
Log.w(TAG, "External high-trust push was locally marked unregistered, but we don't have a UUID, so we can't do anything.", new Throwable());
}
return resolved;