mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 11:08:33 +00:00
Prevent creation of UUID-only recipients.
This commit is contained in:
parent
5c0cf8c1f0
commit
b3e66a9259
@ -155,6 +155,7 @@ public class Recipient {
|
||||
|
||||
return resolved(recipient.getId());
|
||||
} else if (uuid != null) {
|
||||
if (FeatureFlags.UUIDS || e164 != null) {
|
||||
RecipientId id = db.getOrInsertFromUuid(uuid);
|
||||
db.markRegistered(id, uuid);
|
||||
|
||||
@ -163,6 +164,9 @@ public class Recipient {
|
||||
}
|
||||
|
||||
return resolved(id);
|
||||
} else {
|
||||
throw new UuidRecipientError();
|
||||
}
|
||||
} else if (e164 != null) {
|
||||
Recipient recipient = resolved(db.getOrInsertFromE164(e164));
|
||||
|
||||
@ -196,7 +200,19 @@ public class Recipient {
|
||||
RecipientId id = null;
|
||||
|
||||
if (UuidUtil.isUuid(identifier)) {
|
||||
id = db.getOrInsertFromUuid(UuidUtil.parseOrThrow(identifier));
|
||||
UUID uuid = UuidUtil.parseOrThrow(identifier);
|
||||
|
||||
if (FeatureFlags.UUIDS) {
|
||||
id = db.getOrInsertFromUuid(uuid);
|
||||
} else {
|
||||
Optional<RecipientId> possibleId = db.getByUuid(uuid);
|
||||
|
||||
if (possibleId.isPresent()) {
|
||||
id = possibleId.get();
|
||||
} else {
|
||||
throw new UuidRecipientError();
|
||||
}
|
||||
}
|
||||
} else if (GroupUtil.isEncodedGroup(identifier)) {
|
||||
id = db.getOrInsertFromGroupId(identifier);
|
||||
} else if (NumberUtil.isValidEmail(identifier)) {
|
||||
@ -628,4 +644,7 @@ public class Recipient {
|
||||
|
||||
private static class MissingAddressError extends AssertionError {
|
||||
}
|
||||
|
||||
private static class UuidRecipientError extends AssertionError {
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user