Inject api version in call api

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-04 06:19:14 +02:00
parent 33de3ed330
commit f0eb3fec37
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
4 changed files with 57 additions and 13 deletions

View File

@ -302,9 +302,18 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
var hasParticipantsInCall = false
var inCallOnDifferentDevice = false
val apiVersion = ApiUtils.getApiVersion(signatureVerification.userEntity, "conversation", intArrayOf(1))
if (apiVersion == null) {
Log.e(TAG, "No supported API version found")
return
}
ncApi.getPeersForCall(
ApiUtils.getCredentials(signatureVerification.userEntity.username, signatureVerification.userEntity.token),
ApiUtils.getUrlForCall(
apiVersion,
signatureVerification.userEntity.baseUrl,
decryptedPushMessage.id
)
@ -347,4 +356,10 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
}
})
}
companion object {
private val TAG = "MagicFirebaseMessagingService"
private const val ID_DELETE_CONVERSATION_DIALOG = 0
}
}

View File

@ -1302,8 +1302,14 @@ public class CallController extends BaseController {
inCallFlag = (int) Participant.ParticipantFlags.IN_CALL_WITH_AUDIO_AND_VIDEO.getValue();
}
ncApi.joinCall(credentials,
ApiUtils.getUrlForCall(baseUrl, roomToken), inCallFlag)
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
if (apiVersion == null) {
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
return;
}
ncApi.joinCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken), inCallFlag)
.subscribeOn(Schedulers.io())
.retry(3)
.observeOn(AndroidSchedulers.mainThread())
@ -1627,7 +1633,14 @@ public class CallController extends BaseController {
}
private void hangupNetworkCalls(boolean shutDownView) {
ncApi.leaveCall(credentials, ApiUtils.getUrlForCall(baseUrl, roomToken))
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
if (apiVersion == null) {
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
return;
}
ncApi.leaveCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<GenericOverall>() {
@ -1762,7 +1775,14 @@ public class CallController extends BaseController {
private void getPeersForCall() {
Log.d(TAG, "getPeersForCall");
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(baseUrl, roomToken))
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
if (apiVersion == null) {
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
return;
}
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken))
.subscribeOn(Schedulers.io())
.subscribe(new Observer<ParticipantsOverall>() {
@Override

View File

@ -208,8 +208,16 @@ public class CallNotificationController extends BaseController {
.pushChangeHandler(new HorizontalChangeHandler()));
}
@SuppressLint("LongLogTag")
private void checkIfAnyParticipantsRemainInRoom() {
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(userBeingCalled.getBaseUrl(),
Integer apiVersion = ApiUtils.getApiVersion(userBeingCalled, "conversation", new int[] {1});
if (apiVersion == null) {
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
return;
}
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForCall(apiVersion, userBeingCalled.getBaseUrl(),
currentConversation.getToken()))
.subscribeOn(Schedulers.io())
.takeWhile(observable -> !leavingScreen)

View File

@ -196,6 +196,10 @@ public class ApiUtils {
return getUrlForRoom(version, baseUrl, token) + "/webinary/lobby";
}
public static String getUrlForCall(int version, String baseUrl, String token) {
return getUrlForApi(version, baseUrl) + "/call/" + token;
}
public static RetrofitBucket getRetrofitBucketForCreateRoom(int version, String baseUrl, String roomType,
@Nullable String invite,
@Nullable String conversationName) {
@ -243,15 +247,12 @@ public class ApiUtils {
return retrofitBucket;
}
public static String getUrlForCall(String baseUrl, String token) {
// FIXME Introduce API version
return baseUrl + ocsApiVersion + spreedApiVersion + "/call/" + token;
}
/**
* @deprecated Method is only needed before Talk 4 which is from 2018 => todrop
*/
@Deprecated
public static String getUrlForCallPing(String baseUrl, String token) {
// FIXME Introduce API version
return getUrlForCall(baseUrl, token) + "/ping";
return getUrlForCall(1, baseUrl, token) + "/ping";
}
public static String getUrlForChat(String baseUrl, String token) {