mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-02 01:49:56 +01:00
Allow to inject the api version into all methods for the room api
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
1a15bd9f5f
commit
c3061df60b
@ -257,9 +257,11 @@ public class CallNotificationController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
private void handleFromNotification() {
|
private void handleFromNotification() {
|
||||||
Integer apiVersion = ApiUtils.getApiVersion(userBeingCalled, "conversation", new int[] {4, 3, 1});
|
Integer apiVersion = ApiUtils.getApiVersion(userBeingCalled, "conversation", new int[] {4, 3, 1});
|
||||||
if (apiVersion == null) {
|
if (apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,9 +308,12 @@ 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_TOKEN(), roomOverall.getOcs().getData().getToken());
|
||||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
|
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
|
||||||
|
|
||||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
if (apiVersion != null && currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||||
|
|
||||||
ncApi.getRoom(credentials,
|
ncApi.getRoom(credentials,
|
||||||
ApiUtils.getRoom(currentUser.getBaseUrl(),
|
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||||
roomOverall.getOcs().getData().getToken()))
|
roomOverall.getOcs().getData().getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.controllers.bottomsheet;
|
package com.nextcloud.talk.controllers.bottomsheet;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -82,6 +83,8 @@ import retrofit2.HttpException;
|
|||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class OperationsMenuController extends BaseController {
|
public class OperationsMenuController extends BaseController {
|
||||||
|
|
||||||
|
private static final String TAG = "OperationsMenuController";
|
||||||
|
|
||||||
@BindView(R.id.progress_bar)
|
@BindView(R.id.progress_bar)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
|
|
||||||
@ -169,6 +172,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
processOperation();
|
processOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
private void processOperation() {
|
private void processOperation() {
|
||||||
currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
OperationsObserver operationsObserver = new OperationsObserver();
|
OperationsObserver operationsObserver = new OperationsObserver();
|
||||||
@ -189,9 +193,18 @@ public class OperationsMenuController extends BaseController {
|
|||||||
credentials = null;
|
credentials = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
|
||||||
|
if(apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (operationCode) {
|
switch (operationCode) {
|
||||||
case 2:
|
case 2:
|
||||||
ncApi.renameRoom(credentials, ApiUtils.getRoom(currentUser.getBaseUrl(), conversation.getToken()),
|
ncApi.renameRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||||
|
conversation.getToken()),
|
||||||
conversation.getName())
|
conversation.getName())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -199,8 +212,8 @@ public class OperationsMenuController extends BaseController {
|
|||||||
.subscribe(operationsObserver);
|
.subscribe(operationsObserver);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ncApi.makeRoomPublic(credentials, ApiUtils.getUrlForRoomVisibility(currentUser.getBaseUrl(), conversation
|
ncApi.makeRoomPublic(credentials, ApiUtils.getUrlForRoomPublic(apiVersion, currentUser.getBaseUrl(),
|
||||||
.getToken()))
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(1)
|
.retry(1)
|
||||||
@ -213,7 +226,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
if (conversation.getPassword() != null) {
|
if (conversation.getPassword() != null) {
|
||||||
pass = conversation.getPassword();
|
pass = conversation.getPassword();
|
||||||
}
|
}
|
||||||
ncApi.setPassword(credentials, ApiUtils.getUrlForPassword(currentUser.getBaseUrl(),
|
ncApi.setPassword(credentials, ApiUtils.getUrlForRoomPassword(apiVersion, currentUser.getBaseUrl(),
|
||||||
conversation.getToken()), pass)
|
conversation.getToken()), pass)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -224,15 +237,16 @@ public class OperationsMenuController extends BaseController {
|
|||||||
// Operation 7 is sharing, so we handle this differently
|
// Operation 7 is sharing, so we handle this differently
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomVisibility(currentUser.getBaseUrl(), conversation
|
ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomPublic(apiVersion,
|
||||||
.getToken()))
|
currentUser.getBaseUrl(),
|
||||||
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(1)
|
.retry(1)
|
||||||
.subscribe(operationsObserver);
|
.subscribe(operationsObserver);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
ncApi.getRoom(credentials, ApiUtils.getRoom(baseUrl, conversationToken))
|
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, baseUrl, conversationToken))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(1)
|
.retry(1)
|
||||||
@ -300,7 +314,8 @@ public class OperationsMenuController extends BaseController {
|
|||||||
conversation = roomOverall.getOcs().getData();
|
conversation = roomOverall.getOcs().getData();
|
||||||
|
|
||||||
ncApi.getRoom(credentials,
|
ncApi.getRoom(credentials,
|
||||||
ApiUtils.getRoom(currentUser.getBaseUrl(), conversation.getToken()))
|
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||||
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<RoomOverall>() {
|
.subscribe(new Observer<RoomOverall>() {
|
||||||
@ -349,14 +364,18 @@ public class OperationsMenuController extends BaseController {
|
|||||||
case 97:
|
case 97:
|
||||||
case 98:
|
case 98:
|
||||||
if (operationCode == 97) {
|
if (operationCode == 97) {
|
||||||
ncApi.removeConversationFromFavorites(credentials, ApiUtils.getUrlForConversationFavorites(currentUser.getBaseUrl(),
|
ncApi.removeConversationFromFavorites(credentials,
|
||||||
|
ApiUtils.getUrlForRoomFavorite(apiVersion,
|
||||||
|
currentUser.getBaseUrl(),
|
||||||
conversation.getToken()))
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(1)
|
.retry(1)
|
||||||
.subscribe(operationsObserver);
|
.subscribe(operationsObserver);
|
||||||
} else {
|
} else {
|
||||||
ncApi.addConversationToFavorites(credentials, ApiUtils.getUrlForConversationFavorites(currentUser.getBaseUrl(),
|
ncApi.addConversationToFavorites(credentials,
|
||||||
|
ApiUtils.getUrlForRoomFavorite(apiVersion,
|
||||||
|
currentUser.getBaseUrl(),
|
||||||
conversation.getToken()))
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -365,7 +384,9 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 99:
|
case 99:
|
||||||
ncApi.joinRoom(credentials, ApiUtils.getUrlForSettingMyselfAsActiveParticipant(baseUrl, conversationToken),
|
ncApi.joinRoom(credentials, ApiUtils.getUrlForParticipantsActive(apiVersion,
|
||||||
|
baseUrl,
|
||||||
|
conversationToken),
|
||||||
callPassword)
|
callPassword)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -378,8 +399,19 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
private void performGroupCallWorkaround(String credentials) {
|
private void performGroupCallWorkaround(String credentials) {
|
||||||
ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomVisibility(currentUser.getBaseUrl(), conversation.getToken()))
|
|
||||||
|
Integer apiVersion = ApiUtils.getApiVersion(currentUser, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
|
||||||
|
if(apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomPublic(apiVersion, currentUser.getBaseUrl(),
|
||||||
|
conversation.getToken()))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(1)
|
.retry(1)
|
||||||
|
@ -20,7 +20,10 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.jobs;
|
package com.nextcloud.talk.jobs;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.work.Data;
|
import androidx.work.Data;
|
||||||
import androidx.work.Worker;
|
import androidx.work.Worker;
|
||||||
@ -47,6 +50,7 @@ import java.net.CookieManager;
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class DeleteConversationWorker extends Worker {
|
public class DeleteConversationWorker extends Worker {
|
||||||
|
private static final String TAG = "DeleteConversationWorker";
|
||||||
@Inject
|
@Inject
|
||||||
Retrofit retrofit;
|
Retrofit retrofit;
|
||||||
|
|
||||||
@ -66,6 +70,7 @@ public class DeleteConversationWorker extends Worker {
|
|||||||
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Result doWork() {
|
public Result doWork() {
|
||||||
@ -75,6 +80,14 @@ public class DeleteConversationWorker extends Worker {
|
|||||||
UserEntity operationUser = userUtils.getUserWithId(operationUserId);
|
UserEntity operationUser = userUtils.getUserWithId(operationUserId);
|
||||||
|
|
||||||
if (operationUser != null) {
|
if (operationUser != null) {
|
||||||
|
Integer apiVersion = ApiUtils.getApiVersion(operationUser, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
|
||||||
|
if (apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
return Result.failure();
|
||||||
|
}
|
||||||
|
|
||||||
String credentials = ApiUtils.getCredentials(operationUser.getUsername(), operationUser.getToken());
|
String credentials = ApiUtils.getCredentials(operationUser.getUsername(), operationUser.getToken());
|
||||||
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
||||||
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
||||||
@ -82,7 +95,8 @@ public class DeleteConversationWorker extends Worker {
|
|||||||
EventStatus eventStatus = new EventStatus(operationUser.getId(),
|
EventStatus eventStatus = new EventStatus(operationUser.getId(),
|
||||||
EventStatus.EventType.CONVERSATION_UPDATE, true);
|
EventStatus.EventType.CONVERSATION_UPDATE, true);
|
||||||
|
|
||||||
ncApi.deleteRoom(credentials, ApiUtils.getRoom(operationUser.getBaseUrl(), conversationToken))
|
ncApi.deleteRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, operationUser.getBaseUrl(),
|
||||||
|
conversationToken))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.blockingSubscribe(new Observer<GenericOverall>() {
|
.blockingSubscribe(new Observer<GenericOverall>() {
|
||||||
Disposable disposable;
|
Disposable disposable;
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
package com.nextcloud.talk.jobs;
|
package com.nextcloud.talk.jobs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.work.Data;
|
import androidx.work.Data;
|
||||||
import androidx.work.Worker;
|
import androidx.work.Worker;
|
||||||
@ -47,6 +49,9 @@ import java.net.CookieManager;
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class LeaveConversationWorker extends Worker {
|
public class LeaveConversationWorker extends Worker {
|
||||||
|
|
||||||
|
private static final String TAG = "LeaveConversationWorker";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Retrofit retrofit;
|
Retrofit retrofit;
|
||||||
|
|
||||||
@ -82,7 +87,17 @@ public class LeaveConversationWorker extends Worker {
|
|||||||
EventStatus eventStatus = new EventStatus(operationUser.getId(),
|
EventStatus eventStatus = new EventStatus(operationUser.getId(),
|
||||||
EventStatus.EventType.CONVERSATION_UPDATE, true);
|
EventStatus.EventType.CONVERSATION_UPDATE, true);
|
||||||
|
|
||||||
ncApi.removeSelfFromRoom(credentials, ApiUtils.getUrlForRemoveSelfFromRoom(operationUser.getBaseUrl(), conversationToken))
|
Integer apiVersion = ApiUtils.getApiVersion(operationUser, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
|
||||||
|
if(apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
return Result.failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
ncApi.removeSelfFromRoom(credentials, ApiUtils.getUrlForParticipantsSelf(apiVersion,
|
||||||
|
operationUser.getBaseUrl(),
|
||||||
|
conversationToken))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.blockingSubscribe(new Observer<GenericOverall>() {
|
.blockingSubscribe(new Observer<GenericOverall>() {
|
||||||
Disposable disposable;
|
Disposable disposable;
|
||||||
|
@ -152,8 +152,16 @@ public class NotificationWorker extends Worker {
|
|||||||
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
|
importantConversation = Boolean.parseBoolean(arbitraryStorageEntity.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer apiVersion = ApiUtils.getApiVersion(userEntity, "conversation",
|
||||||
|
new int[] {1});
|
||||||
|
|
||||||
ncApi.getRoom(credentials, ApiUtils.getRoom(userEntity.getBaseUrl(),
|
if (apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, userEntity.getBaseUrl(),
|
||||||
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
|
intent.getExtras().getString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN())))
|
||||||
.blockingSubscribe(new Observer<RoomOverall>() {
|
.blockingSubscribe(new Observer<RoomOverall>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,12 +52,12 @@ public class ApiUtils {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForLobbyForConversation(String baseUrl, String token) {
|
public static String getUrlForLobbyForConversation(String baseUrl, String token) {
|
||||||
return getRoom(baseUrl, token) + "/webinary/lobby";
|
return getUrlForRoomWebinaryLobby(1, baseUrl, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForRemovingParticipantFromConversation(String baseUrl, String roomToken, boolean isGuest) {
|
public static String getUrlForRemovingParticipantFromConversation(String baseUrl, String roomToken, boolean isGuest) {
|
||||||
String url = getUrlForParticipants(baseUrl, roomToken);
|
String url = getUrlForParticipants(1, baseUrl, roomToken);
|
||||||
|
|
||||||
if (isGuest) {
|
if (isGuest) {
|
||||||
url += "/guests";
|
url += "/guests";
|
||||||
@ -108,22 +108,13 @@ public class ApiUtils {
|
|||||||
return retrofitBucket;
|
return retrofitBucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Please specify the api version you want to use via
|
|
||||||
* {@link ApiUtils#getUrlForRoomNotificationLevel(int, String, String)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForSettingNotificationlevel(String baseUrl, String token) {
|
|
||||||
return getRoom(baseUrl, token) + "/notify";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Please specify the api version you want to use via
|
* @deprecated Please specify the api version you want to use via
|
||||||
* {@link ApiUtils#getUrlForParticipantsActive(int, String, String)} instead.
|
* {@link ApiUtils#getUrlForParticipantsActive(int, String, String)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForSettingMyselfAsActiveParticipant(String baseUrl, String token) {
|
public static String getUrlForSettingMyselfAsActiveParticipant(String baseUrl, String token) {
|
||||||
return getRoom(baseUrl, token) + "/participants/active";
|
return getUrlForParticipantsActive(1, baseUrl, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,10 +178,34 @@ public class ApiUtils {
|
|||||||
return getUrlForParticipants(version, baseUrl, token) + "/active";
|
return getUrlForParticipants(version, baseUrl, token) + "/active";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUrlForParticipantsSelf(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForParticipants(version, baseUrl, token) + "/self";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUrlForRoomFavorite(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/favorite";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUrlForRoomModerators(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/moderators";
|
||||||
|
}
|
||||||
|
|
||||||
public static String getUrlForRoomNotificationLevel(int version, String baseUrl, String token) {
|
public static String getUrlForRoomNotificationLevel(int version, String baseUrl, String token) {
|
||||||
return getUrlForRoom(version, baseUrl, token) + "/notify";
|
return getUrlForRoom(version, baseUrl, token) + "/notify";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUrlForRoomPublic(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/public";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUrlForRoomPassword(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/password";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUrlForRoomReadOnlyState(int version, String baseUrl, String token) {
|
||||||
|
return getUrlForRoom(version, baseUrl, token) + "/read-only";
|
||||||
|
}
|
||||||
|
|
||||||
public static String getUrlForRoomWebinaryLobby(int version, String baseUrl, String token) {
|
public static String getUrlForRoomWebinaryLobby(int version, String baseUrl, String token) {
|
||||||
return getUrlForRoom(version, baseUrl, token) + "/webinary/lobby";
|
return getUrlForRoom(version, baseUrl, token) + "/webinary/lobby";
|
||||||
}
|
}
|
||||||
@ -244,18 +259,9 @@ public class ApiUtils {
|
|||||||
return retrofitBucket;
|
return retrofitBucket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForRemoveSelfFromRoom(String baseUrl, String token) {
|
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/participants/self";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForRoomVisibility(String baseUrl, String token) {
|
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/public";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForCall(String baseUrl, String token) {
|
public static String getUrlForCall(String baseUrl, String token) {
|
||||||
|
// FIXME user APIv4
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/call/" + token;
|
return baseUrl + ocsApiVersion + spreedApiVersion + "/call/" + token;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -265,23 +271,22 @@ public class ApiUtils {
|
|||||||
return getUrlForCall(baseUrl, token) + "/ping";
|
return getUrlForCall(baseUrl, token) + "/ping";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForChat(String baseUrl, String token) {
|
public static String getUrlForChat(String baseUrl, String token) {
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/chat/" + token;
|
return baseUrl + ocsApiVersion + spreedApiVersion + "/chat/" + token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForExternalServerAuthBackend(String baseUrl) {
|
public static String getUrlForExternalServerAuthBackend(String baseUrl) {
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/signaling/backend";
|
return getUrlForSignaling(baseUrl, null) + "/backend";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForMentionSuggestions(String baseUrl, String token) {
|
public static String getUrlForMentionSuggestions(String baseUrl, String token) {
|
||||||
return getUrlForChat(baseUrl, token) + "/mentions";
|
return getUrlForChat(baseUrl, token) + "/mentions";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForSignaling(String baseUrl, @Nullable String token) {
|
public static String getUrlForSignaling(String baseUrl, @Nullable String token) {
|
||||||
|
// FIXME use APIv2 ?
|
||||||
String signalingUrl = baseUrl + ocsApiVersion + spreedApiVersion + "/signaling";
|
String signalingUrl = baseUrl + ocsApiVersion + spreedApiVersion + "/signaling";
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
return signalingUrl;
|
return signalingUrl;
|
||||||
@ -290,9 +295,13 @@ public class ApiUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please specify the api version you want to use via
|
||||||
|
* {@link ApiUtils#getUrlForRoomModerators(int, String, String)} instead.
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String getUrlForModerators(String baseUrl, String roomToken) {
|
public static String getUrlForModerators(String baseUrl, String roomToken) {
|
||||||
return getRoom(baseUrl, roomToken) + "/moderators";
|
return getUrlForRoomModerators(1, baseUrl, roomToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -309,7 +318,6 @@ public class ApiUtils {
|
|||||||
return baseUrl + ocsApiVersion + "/cloud/users/" + userId;
|
return baseUrl + ocsApiVersion + "/cloud/users/" + userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForUserSettings(String baseUrl) {
|
public static String getUrlForUserSettings(String baseUrl) {
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/settings/user";
|
return baseUrl + ocsApiVersion + spreedApiVersion + "/settings/user";
|
||||||
}
|
}
|
||||||
@ -337,11 +345,6 @@ public class ApiUtils {
|
|||||||
return baseUrl + "/index.php/avatar/guest/" + Uri.encode(name) + "/" + avatarSize;
|
return baseUrl + "/index.php/avatar/guest/" + Uri.encode(name) + "/" + avatarSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForPassword(String baseUrl, String token) {
|
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/password";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getCredentials(String username, String token) {
|
public static String getCredentials(String username, String token) {
|
||||||
if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) {
|
if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) {
|
||||||
return null;
|
return null;
|
||||||
@ -358,20 +361,10 @@ public class ApiUtils {
|
|||||||
getApplicationContext().getResources().getString(R.string.nc_push_server_url) + "/devices";
|
getApplicationContext().getResources().getString(R.string.nc_push_server_url) + "/devices";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForConversationFavorites(String baseUrl, String roomToken) {
|
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + roomToken + "/favorite";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUrlForNotificationWithId(String baseUrl, String notificationId) {
|
public static String getUrlForNotificationWithId(String baseUrl, String notificationId) {
|
||||||
return baseUrl + ocsApiVersion + "/apps/notifications/api/v2/notifications/" + notificationId;
|
return baseUrl + ocsApiVersion + "/apps/notifications/api/v2/notifications/" + notificationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForReadOnlyState(String baseUrl, String roomToken) {
|
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + roomToken + "/read-only";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUrlForSearchByNumber(String baseUrl) {
|
public static String getUrlForSearchByNumber(String baseUrl) {
|
||||||
return baseUrl + ocsApiVersion + "/cloud/users/search/by-phone";
|
return baseUrl + ocsApiVersion + "/cloud/users/search/by-phone";
|
||||||
}
|
}
|
||||||
@ -384,9 +377,8 @@ public class ApiUtils {
|
|||||||
return baseUrl + "/remote.php/dav/files/" + user + "/" + remotePath;
|
return baseUrl + "/remote.php/dav/files/" + user + "/" + remotePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static String getUrlForMessageDeletion(String baseUrl, String token, String messageId) {
|
public static String getUrlForMessageDeletion(String baseUrl, String token, String messageId) {
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/chat/" + token + "/" + messageId;
|
return getUrlForChat(baseUrl, token) + "/" + messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUrlForTempAvatar(String baseUrl) {
|
public static String getUrlForTempAvatar(String baseUrl) {
|
||||||
|
@ -22,6 +22,8 @@ package com.nextcloud.talk.utils.preferences.preferencestorage;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
@ -40,6 +42,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class DatabaseStorageModule implements StorageModule {
|
public class DatabaseStorageModule implements StorageModule {
|
||||||
|
private static final String TAG = "DatabaseStorageModule";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ArbitraryStorageUtils arbitraryStorageUtils;
|
ArbitraryStorageUtils arbitraryStorageUtils;
|
||||||
|
|
||||||
@ -53,6 +57,7 @@ public class DatabaseStorageModule implements StorageModule {
|
|||||||
private boolean lobbyValue;
|
private boolean lobbyValue;
|
||||||
|
|
||||||
private String messageNotificationLevel;
|
private String messageNotificationLevel;
|
||||||
|
|
||||||
public DatabaseStorageModule(UserEntity conversationUser, String conversationToken) {
|
public DatabaseStorageModule(UserEntity conversationUser, String conversationToken) {
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
@ -92,8 +97,14 @@ public class DatabaseStorageModule implements StorageModule {
|
|||||||
intValue = 0;
|
intValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer apiVersion = ApiUtils.getApiVersion(conversationUser, "conversation", new int[] {4, 1});
|
||||||
|
if (apiVersion == null) {
|
||||||
|
Log.e(TAG, "No supported API version found", new Exception("No supported API version found"));
|
||||||
|
}
|
||||||
|
|
||||||
ncApi.setNotificationLevel(ApiUtils.getCredentials(conversationUser.getUsername(), conversationUser.getToken()),
|
ncApi.setNotificationLevel(ApiUtils.getCredentials(conversationUser.getUsername(), conversationUser.getToken()),
|
||||||
ApiUtils.getUrlForSettingNotificationlevel(conversationUser.getBaseUrl(), conversationToken),
|
ApiUtils.getUrlForRoomNotificationLevel(apiVersion, conversationUser.getBaseUrl(),
|
||||||
|
conversationToken),
|
||||||
intValue)
|
intValue)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(new Observer<GenericOverall>() {
|
.subscribe(new Observer<GenericOverall>() {
|
||||||
|
Loading…
Reference in New Issue
Block a user