mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Change version to be specific to conversations api
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e6d869d431
commit
529541d896
@ -303,7 +303,7 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() {
|
||||
var inCallOnDifferentDevice = false
|
||||
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(signatureVerification.userEntity, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(signatureVerification.userEntity, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
|
@ -231,7 +231,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
val roomType = "1"
|
||||
val currentUser = userUtils.currentUser ?: return
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -258,7 +258,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
bundle.putString(KEY_ROOM_TOKEN, roomOverall.ocs.data.token)
|
||||
bundle.putString(KEY_ROOM_ID, roomOverall.ocs.data.roomId)
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
val apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
|
@ -441,7 +441,7 @@ public class CallController extends BaseController {
|
||||
}
|
||||
|
||||
private void handleFromNotification() {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -1248,8 +1248,7 @@ public class CallController extends BaseController {
|
||||
private void joinRoomAndCall() {
|
||||
callSession = ApplicationWideCurrentRoomHolder.getInstance().getSession();
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
return;
|
||||
@ -1309,7 +1308,7 @@ public class CallController extends BaseController {
|
||||
inCallFlag = (int) Participant.ParticipantFlags.IN_CALL_WITH_AUDIO_AND_VIDEO.getValue();
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -1648,7 +1647,7 @@ public class CallController extends BaseController {
|
||||
}
|
||||
|
||||
private void hangupNetworkCalls(boolean shutDownView) {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -1690,8 +1689,7 @@ public class CallController extends BaseController {
|
||||
}
|
||||
|
||||
private void leaveRoom(boolean shutDownView) {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
return;
|
||||
@ -1790,7 +1788,7 @@ public class CallController extends BaseController {
|
||||
|
||||
private void getPeersForCall() {
|
||||
Log.d(TAG, "getPeersForCall");
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -210,7 +210,7 @@ public class CallNotificationController extends BaseController {
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
private void checkIfAnyParticipantsRemainInRoom() {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(userBeingCalled, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(userBeingCalled, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -267,7 +267,7 @@ public class CallNotificationController extends BaseController {
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
private void handleFromNotification() {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(userBeingCalled, "conversation", new int[] {4, 3, 1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(userBeingCalled, new int[] {4, 3, 1});
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
return;
|
||||
|
@ -294,7 +294,7 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
if (conversationUser != null) {
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -344,7 +344,7 @@ class ChatController(args: Bundle) :
|
||||
return
|
||||
}
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -977,7 +977,7 @@ class ChatController(args: Bundle) :
|
||||
if (currentConversation == null || TextUtils.isEmpty(currentConversation?.sessionId) ||
|
||||
currentConversation?.sessionId == "0"
|
||||
) {
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -1051,7 +1051,7 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
private fun leaveRoom() {
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -1806,7 +1806,7 @@ class ChatController(args: Bundle) :
|
||||
currentConversation?.name != userMentionClickEvent.userId
|
||||
) {
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
|
@ -288,7 +288,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
userId = selectedUserIds.iterator().next();
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -318,8 +318,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
if (apiVersion != null && currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
|
||||
ncApi.getRoom(credentials,
|
||||
@ -861,7 +860,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
roomType = "2";
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -310,7 +310,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
).isChecked
|
||||
) 1 else 0
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -449,7 +449,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
}
|
||||
|
||||
private fun getListOfParticipants() {
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -545,7 +545,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
}
|
||||
|
||||
private fun fetchRoomInfo() {
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
@ -726,7 +726,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
title(text = participant.displayName)
|
||||
listItemsWithImage(items = items) { dialog, index, _ ->
|
||||
|
||||
val apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", intArrayOf(1))
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found")
|
||||
|
@ -418,7 +418,7 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
|
||||
callItems = new ArrayList<>();
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", new int[] {4, 1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {4, 1});
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
return;
|
||||
|
@ -193,8 +193,7 @@ public class OperationsMenuController extends BaseController {
|
||||
credentials = null;
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -402,8 +401,7 @@ public class OperationsMenuController extends BaseController {
|
||||
@SuppressLint("LongLogTag")
|
||||
private void performGroupCallWorkaround(String credentials) {
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
@ -567,7 +565,7 @@ public class OperationsMenuController extends BaseController {
|
||||
localInvitedGroups.remove(0);
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -70,7 +70,7 @@ public class AddParticipantsToConversation extends Worker {
|
||||
public Result doWork() {
|
||||
UserEntity user = userUtils.getUserWithInternalId(data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1));
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(user, "conversation", new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -80,8 +80,7 @@ public class DeleteConversationWorker extends Worker {
|
||||
UserEntity operationUser = userUtils.getUserWithId(operationUserId);
|
||||
|
||||
if (operationUser != null) {
|
||||
Integer apiVersion = ApiUtils.getApiVersion(operationUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(operationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -87,8 +87,7 @@ public class LeaveConversationWorker extends Worker {
|
||||
EventStatus eventStatus = new EventStatus(operationUser.getId(),
|
||||
EventStatus.EventType.CONVERSATION_UPDATE, true);
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(operationUser, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(operationUser, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -152,8 +152,7 @@ public class NotificationWorker extends Worker {
|
||||
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(userEntity, "conversation",
|
||||
new int[] {1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(userEntity, new int[] {1});
|
||||
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
|
@ -109,30 +109,28 @@ public class ApiUtils {
|
||||
return baseUrl + ocsApiVersion + "/cloud/capabilities";
|
||||
}
|
||||
|
||||
public static Integer getApiVersion(UserEntity capabilities, String apiName, int[] versions) {
|
||||
if (apiName.equals("conversation")) {
|
||||
boolean hasApiV4 = false;
|
||||
for (int version : versions) {
|
||||
hasApiV4 |= version == 4;
|
||||
}
|
||||
public static Integer getConversationApiVersion(UserEntity capabilities, int[] versions) {
|
||||
boolean hasApiV4 = false;
|
||||
for (int version : versions) {
|
||||
hasApiV4 |= version == 4;
|
||||
}
|
||||
|
||||
if (!hasApiV4) {
|
||||
Exception e = new Exception("Api call did not try conversation-v4 api");
|
||||
Log.d(TAG, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (!hasApiV4) {
|
||||
Exception e = new Exception("Api call did not try conversation-v4 api");
|
||||
Log.d(TAG, e.getMessage(), e);
|
||||
}
|
||||
|
||||
for (int version : versions) {
|
||||
if (capabilities.hasSpreedFeatureCapability(apiName + "-v" + version)) {
|
||||
if (capabilities.hasSpreedFeatureCapability("conversation-v" + version)) {
|
||||
return version;
|
||||
}
|
||||
|
||||
// Fallback for old API versions
|
||||
if (apiName.equals("conversation") && (version == 1 || version == 2)) {
|
||||
if (capabilities.hasSpreedFeatureCapability(apiName + "-v2")) {
|
||||
if ((version == 1 || version == 2)) {
|
||||
if (capabilities.hasSpreedFeatureCapability("conversation-v2")) {
|
||||
return version;
|
||||
}
|
||||
if (version == 1 && capabilities.hasSpreedFeatureCapability(apiName)) {
|
||||
if (version == 1 && capabilities.hasSpreedFeatureCapability("conversation")) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class DatabaseStorageModule implements StorageModule {
|
||||
intValue = 0;
|
||||
}
|
||||
|
||||
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {4, 1});
|
||||
Integer apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[] {4, 1});
|
||||
if (apiVersion == null) {
|
||||
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user