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,14 +155,18 @@ public class Recipient {
|
|||||||
|
|
||||||
return resolved(recipient.getId());
|
return resolved(recipient.getId());
|
||||||
} else if (uuid != null) {
|
} else if (uuid != null) {
|
||||||
RecipientId id = db.getOrInsertFromUuid(uuid);
|
if (FeatureFlags.UUIDS || e164 != null) {
|
||||||
db.markRegistered(id, uuid);
|
RecipientId id = db.getOrInsertFromUuid(uuid);
|
||||||
|
db.markRegistered(id, uuid);
|
||||||
|
|
||||||
if (e164 != null) {
|
if (e164 != null) {
|
||||||
db.setPhoneNumber(id, e164);
|
db.setPhoneNumber(id, e164);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolved(id);
|
||||||
|
} else {
|
||||||
|
throw new UuidRecipientError();
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolved(id);
|
|
||||||
} else if (e164 != null) {
|
} else if (e164 != null) {
|
||||||
Recipient recipient = resolved(db.getOrInsertFromE164(e164));
|
Recipient recipient = resolved(db.getOrInsertFromE164(e164));
|
||||||
|
|
||||||
@ -196,7 +200,19 @@ public class Recipient {
|
|||||||
RecipientId id = null;
|
RecipientId id = null;
|
||||||
|
|
||||||
if (UuidUtil.isUuid(identifier)) {
|
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)) {
|
} else if (GroupUtil.isEncodedGroup(identifier)) {
|
||||||
id = db.getOrInsertFromGroupId(identifier);
|
id = db.getOrInsertFromGroupId(identifier);
|
||||||
} else if (NumberUtil.isValidEmail(identifier)) {
|
} else if (NumberUtil.isValidEmail(identifier)) {
|
||||||
@ -628,4 +644,7 @@ public class Recipient {
|
|||||||
|
|
||||||
private static class MissingAddressError extends AssertionError {
|
private static class MissingAddressError extends AssertionError {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class UuidRecipientError extends AssertionError {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user