mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Fix capability checking when there could be no user
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
6aab2d0834
commit
9f0c760c49
@ -334,7 +334,11 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
private fun handleFromNotification() {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Can this be called for guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi?.getRooms(credentials, ApiUtils.getUrlForRooms(apiVersion, conversationUser?.baseUrl))
|
||||
?.subscribeOn(Schedulers.io())?.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -962,7 +966,11 @@ class ChatController(args: Bundle) :
|
||||
if (currentConversation == null || TextUtils.isEmpty(currentConversation?.sessionId) ||
|
||||
currentConversation?.sessionId == "0"
|
||||
) {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi?.joinRoom(
|
||||
credentials,
|
||||
@ -1031,7 +1039,11 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
private fun leaveRoom() {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi?.leaveRoom(
|
||||
credentials,
|
||||
@ -1221,9 +1233,8 @@ class ChatController(args: Bundle) :
|
||||
}
|
||||
|
||||
if (!wasDetached) {
|
||||
var apiVersion: Int
|
||||
var apiVersion = 1
|
||||
// FIXME this is a best guess, guests would need to get the capabilities themselves
|
||||
apiVersion = 1
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
@ -1651,7 +1662,12 @@ class ChatController(args: Bundle) :
|
||||
true
|
||||
}
|
||||
R.id.action_delete_message -> {
|
||||
val apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi?.deleteChatMessage(
|
||||
credentials,
|
||||
ApiUtils.getUrlForChatMessage(
|
||||
@ -1769,7 +1785,11 @@ class ChatController(args: Bundle) :
|
||||
currentConversation?.name != userMentionClickEvent.userId
|
||||
) {
|
||||
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||
apiVersion, conversationUser?.baseUrl, "1",
|
||||
|
@ -312,9 +312,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());
|
||||
|
||||
int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
|
||||
ncApi.getRoom(credentials,
|
||||
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||
roomOverall.getOcs().getData().getToken()))
|
||||
|
@ -441,7 +441,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
}
|
||||
|
||||
private fun getListOfParticipants() {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi.getPeersForCall(
|
||||
credentials,
|
||||
@ -532,7 +536,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
}
|
||||
|
||||
private fun fetchRoomInfo() {
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
var apiVersion = 1
|
||||
// FIXME Fix API checking with guests?
|
||||
if (conversationUser != null) {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(1))
|
||||
}
|
||||
|
||||
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, conversationUser!!.baseUrl, conversationToken))
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -185,11 +185,15 @@ public class OperationsMenuController extends BaseController {
|
||||
if (currentUser != null) {
|
||||
credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
|
||||
|
||||
int apiVersion;
|
||||
if (!TextUtils.isEmpty(baseUrl) && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||
credentials = null;
|
||||
// FIXME joining a public link we need to check other capabilities
|
||||
apiVersion = 1;
|
||||
} else {
|
||||
apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
}
|
||||
|
||||
int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
||||
|
||||
switch (operationCode) {
|
||||
case 2:
|
||||
|
Loading…
Reference in New Issue
Block a user