mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Store your own PNI.
This commit is contained in:
@@ -176,10 +176,6 @@ public class SignalServiceAccountManager {
|
||||
this.pushServiceSocket.removeRegistrationLockV1();
|
||||
}
|
||||
|
||||
public ACI getOwnAci() throws IOException {
|
||||
return this.pushServiceSocket.getOwnAci();
|
||||
}
|
||||
|
||||
public WhoAmIResponse getWhoAmI() throws IOException {
|
||||
return this.pushServiceSocket.getWhoAmI();
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
|
||||
/**
|
||||
* An ACI is an "Account Identity". They're just UUIDs, but given multiple different things could be UUIDs, this wrapper exists to give us type safety around
|
||||
* this *specific type* of UUID.
|
||||
@@ -65,7 +63,7 @@ public final class ACI extends AccountIdentifier {
|
||||
return uuid != null ? uuid : UNKNOWN;
|
||||
}
|
||||
|
||||
public static List<ACI> filterKnown(@NonNull Collection<ACI> acis) {
|
||||
public static List<ACI> filterKnown(Collection<ACI> acis) {
|
||||
return acis.stream().filter(aci -> !aci.equals(UNKNOWN)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@ public final class PNI extends AccountIdentifier {
|
||||
return uuid != null ? from(uuid) : null;
|
||||
}
|
||||
|
||||
public static PNI parseOrThrow(String raw) {
|
||||
return from(UUID.fromString(raw));
|
||||
}
|
||||
|
||||
private PNI(UUID uuid) {
|
||||
super(uuid);
|
||||
}
|
||||
@@ -36,4 +40,9 @@ public final class PNI extends AccountIdentifier {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return uuid.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,18 +327,6 @@ public class PushServiceSocket {
|
||||
makeServiceRequest(path, "GET", null, headers, new VerificationCodeResponseHandler());
|
||||
}
|
||||
|
||||
public ACI getOwnAci() throws IOException {
|
||||
String body = makeServiceRequest(WHO_AM_I, "GET", null);
|
||||
WhoAmIResponse response = JsonUtil.fromJson(body, WhoAmIResponse.class);
|
||||
Optional<ACI> aci = ACI.parse(response.getAci());
|
||||
|
||||
if (aci.isPresent()) {
|
||||
return aci.get();
|
||||
} else {
|
||||
throw new IOException("Invalid UUID!");
|
||||
}
|
||||
}
|
||||
|
||||
public WhoAmIResponse getWhoAmI() throws IOException {
|
||||
return JsonUtil.fromJson(makeServiceRequest(WHO_AM_I, "GET", null), WhoAmIResponse.class);
|
||||
}
|
||||
@@ -580,7 +568,7 @@ public class PushServiceSocket {
|
||||
signedPreKey.getKeyPair().getPublicKey(),
|
||||
signedPreKey.getSignature());
|
||||
|
||||
makeServiceRequest(String.format(PREKEY_PATH, ""), "PUT",
|
||||
String response = makeServiceRequest(String.format(PREKEY_PATH, ""), "PUT",
|
||||
JsonUtil.toJson(new PreKeyState(entities, signedPreKeyEntity, identityKey)));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ public class VerifyAccountResponse {
|
||||
@JsonProperty
|
||||
private String uuid;
|
||||
|
||||
@JsonProperty
|
||||
private String pni;
|
||||
|
||||
@JsonProperty
|
||||
private boolean storageCapable;
|
||||
|
||||
@@ -16,4 +19,8 @@ public class VerifyAccountResponse {
|
||||
public boolean isStorageCapable() {
|
||||
return storageCapable;
|
||||
}
|
||||
|
||||
public String getPni() {
|
||||
return pni;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user