Use v2/calling/relays endpoint.

This commit is contained in:
adel-signal 2024-10-29 12:58:36 -07:00 committed by GitHub
parent 4220068835
commit 47300bbd56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 23 deletions

View file

@ -1027,14 +1027,7 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
public void retrieveTurnServers(@NonNull RemotePeer remotePeer) {
networkExecutor.execute(() -> {
try {
TurnServerInfo turnServerInfo = AppDependencies.getSignalServiceAccountManager().getTurnServerInfo();
List<TurnServerInfo> turnServerInfos = new ArrayList<>();
if (turnServerInfo != null) {
turnServerInfos.add(turnServerInfo);
turnServerInfos.addAll(turnServerInfo.getIceServers());
}
List<TurnServerInfo> turnServerInfos = AppDependencies.getSignalServiceAccountManager().getTurnServerInfo();
List<PeerConnection.IceServer> iceServers = mapToIceServers(turnServerInfos);
process((s, p) -> {
RemotePeer activePeer = s.getCallInfoState().getActivePeer();

View file

@ -552,8 +552,9 @@ public class SignalServiceAccountManager {
this.pushServiceSocket.removeDevice(deviceId);
}
public TurnServerInfo getTurnServerInfo() throws IOException {
return this.pushServiceSocket.getTurnServerInfo();
public List<TurnServerInfo> getTurnServerInfo() throws IOException {
List<TurnServerInfo> relays = this.pushServiceSocket.getCallingRelays().getRelays();
return relays != null ? relays : Collections.emptyList();
}
public void checkNetworkConnection() throws IOException {

View file

@ -3,7 +3,6 @@ package org.whispersystems.signalservice.api.messages.calls;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections;
import java.util.List;
public class TurnServerInfo {
@ -23,9 +22,6 @@ public class TurnServerInfo {
@JsonProperty
private List<String> urlsWithIps;
@JsonProperty
private List<TurnServerInfo> iceServers;
public String getUsername() {
return username;
}
@ -46,8 +42,4 @@ public class TurnServerInfo {
public List<String> getUrlsWithIps() {
return urlsWithIps;
}
public List<TurnServerInfo> getIceServers() {
return (iceServers != null) ? iceServers : Collections.emptyList();
}
}

View file

@ -0,0 +1,17 @@
/*
* Copyright 2024 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.signalservice.internal.push
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import org.whispersystems.signalservice.api.messages.calls.TurnServerInfo
/**
* Response body for GetCallingRelays
*/
data class GetCallingRelaysResponse @JsonCreator constructor(
@JsonProperty("relays") val relays: List<TurnServerInfo>?
)

View file

@ -71,7 +71,6 @@ import org.whispersystems.signalservice.api.link.WaitForLinkedDeviceResponse;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment.ProgressListener;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId;
import org.whispersystems.signalservice.api.messages.calls.CallingResponse;
import org.whispersystems.signalservice.api.messages.calls.TurnServerInfo;
import org.whispersystems.signalservice.api.messages.multidevice.DeviceInfo;
import org.whispersystems.signalservice.api.payments.CurrencyConversions;
import org.whispersystems.signalservice.api.profiles.ProfileAndCredential;
@ -249,7 +248,7 @@ public class PushServiceSocket {
private static final String PREKEY_DEVICE_PATH = "/v2/keys/%s/%s";
private static final String PREKEY_CHECK_PATH = "/v2/keys/check";
private static final String TURN_SERVER_INFO = "/v1/calling/relays";
private static final String CALLING_RELAYS = "/v2/calling/relays";
private static final String PROVISIONING_CODE_PATH = "/v1/devices/provisioning/code";
private static final String PROVISIONING_MESSAGE_PATH = "/v1/provisioning/%s";
@ -1551,9 +1550,9 @@ public class PushServiceSocket {
return getAuthCredentials(PAYMENTS_AUTH_PATH);
}
public TurnServerInfo getTurnServerInfo() throws IOException {
String response = makeServiceRequest(TURN_SERVER_INFO, "GET", null);
return JsonUtil.fromJson(response, TurnServerInfo.class);
public GetCallingRelaysResponse getCallingRelays() throws IOException {
String response = makeServiceRequest(CALLING_RELAYS, "GET", null);
return JsonUtil.fromJson(response, GetCallingRelaysResponse.class);
}
public String getStorageAuth() throws IOException {