mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +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() {
|
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))
|
ncApi?.getRooms(credentials, ApiUtils.getUrlForRooms(apiVersion, conversationUser?.baseUrl))
|
||||||
?.subscribeOn(Schedulers.io())?.observeOn(AndroidSchedulers.mainThread())
|
?.subscribeOn(Schedulers.io())?.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -962,7 +966,11 @@ class ChatController(args: Bundle) :
|
|||||||
if (currentConversation == null || TextUtils.isEmpty(currentConversation?.sessionId) ||
|
if (currentConversation == null || TextUtils.isEmpty(currentConversation?.sessionId) ||
|
||||||
currentConversation?.sessionId == "0"
|
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(
|
ncApi?.joinRoom(
|
||||||
credentials,
|
credentials,
|
||||||
@ -1031,7 +1039,11 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun leaveRoom() {
|
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(
|
ncApi?.leaveRoom(
|
||||||
credentials,
|
credentials,
|
||||||
@ -1221,9 +1233,8 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wasDetached) {
|
if (!wasDetached) {
|
||||||
var apiVersion: Int
|
var apiVersion = 1
|
||||||
// FIXME this is a best guess, guests would need to get the capabilities themselves
|
// FIXME this is a best guess, guests would need to get the capabilities themselves
|
||||||
apiVersion = 1
|
|
||||||
if (conversationUser != null) {
|
if (conversationUser != null) {
|
||||||
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||||
}
|
}
|
||||||
@ -1651,7 +1662,12 @@ class ChatController(args: Bundle) :
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_delete_message -> {
|
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(
|
ncApi?.deleteChatMessage(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForChatMessage(
|
ApiUtils.getUrlForChatMessage(
|
||||||
@ -1769,7 +1785,11 @@ class ChatController(args: Bundle) :
|
|||||||
currentConversation?.name != userMentionClickEvent.userId
|
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(
|
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
|
||||||
apiVersion, conversationUser?.baseUrl, "1",
|
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_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());
|
||||||
|
|
||||||
int apiVersion = ApiUtils.getConversationApiVersion(currentUser, new int[] {1});
|
|
||||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||||
|
|
||||||
ncApi.getRoom(credentials,
|
ncApi.getRoom(credentials,
|
||||||
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||||
roomOverall.getOcs().getData().getToken()))
|
roomOverall.getOcs().getData().getToken()))
|
||||||
|
@ -441,7 +441,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getListOfParticipants() {
|
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(
|
ncApi.getPeersForCall(
|
||||||
credentials,
|
credentials,
|
||||||
@ -532,7 +536,11 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchRoomInfo() {
|
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))
|
ncApi.getRoom(credentials, ApiUtils.getUrlForRoom(apiVersion, conversationUser!!.baseUrl, conversationToken))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
@ -185,11 +185,15 @@ public class OperationsMenuController extends BaseController {
|
|||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
|
credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
|
||||||
|
|
||||||
|
int apiVersion;
|
||||||
if (!TextUtils.isEmpty(baseUrl) && !baseUrl.equals(currentUser.getBaseUrl())) {
|
if (!TextUtils.isEmpty(baseUrl) && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||||
credentials = null;
|
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) {
|
switch (operationCode) {
|
||||||
case 2:
|
case 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user