mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-19 01:45:58 +01:00
Fix promoting and demoting on apiv4
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
6f48ff9070
commit
596772c5c6
@ -142,12 +142,20 @@ public interface NcApi {
|
||||
@DELETE
|
||||
Observable<GenericOverall> removeAttendeeFromConversation(@Header("Authorization") String authorization, @Url String url, @Query("attendeeId") Long attendeeId);
|
||||
|
||||
@Deprecated
|
||||
@POST
|
||||
Observable<GenericOverall> promoteUserToModerator(@Header("Authorization") String authorization, @Url String url, @Query("participant") String participantId);
|
||||
|
||||
@Deprecated
|
||||
@DELETE
|
||||
Observable<GenericOverall> demoteModeratorToUser(@Header("Authorization") String authorization, @Url String url, @Query("participant") String participantId);
|
||||
|
||||
@POST
|
||||
Observable<GenericOverall> promoteAttendeeToModerator(@Header("Authorization") String authorization, @Url String url, @Query("attendeeId") Long attendeeId);
|
||||
|
||||
@DELETE
|
||||
Observable<GenericOverall> demoteAttendeeFromModerator(@Header("Authorization") String authorization, @Url String url, @Query("attendeeId") Long attendeeId);
|
||||
|
||||
/*
|
||||
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /room/roomToken/participants/self
|
||||
*/
|
||||
|
@ -704,6 +704,8 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
val userItem = adapter?.getItem(position) as UserItem
|
||||
val participant = userItem.model
|
||||
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||
|
||||
if (participant.userId != conversationUser!!.userId) {
|
||||
var items = mutableListOf(
|
||||
BasicListItemWithImage(R.drawable.ic_pencil_grey600_24dp, context.getString(R.string.nc_promote)),
|
||||
@ -730,40 +732,97 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
|
||||
|
||||
title(text = participant.displayName)
|
||||
listItemsWithImage(items = items) { dialog, index, _ ->
|
||||
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||
|
||||
if (index == 0) {
|
||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||
ncApi.demoteModeratorToUser(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.userId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
getListOfParticipants()
|
||||
}
|
||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
||||
ncApi.promoteUserToModerator(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.userId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
getListOfParticipants()
|
||||
}
|
||||
if (apiVersion >= ApiUtils.APIv4) {
|
||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||
ncApi.demoteAttendeeFromModerator(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.attendeeId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<GenericOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
}
|
||||
|
||||
override fun onNext(genericOverall: GenericOverall) {
|
||||
getListOfParticipants()
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Error demoting an attendee from moderators", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
}
|
||||
})
|
||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
||||
ncApi.promoteAttendeeToModerator(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.attendeeId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<GenericOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
}
|
||||
|
||||
override fun onNext(genericOverall: GenericOverall) {
|
||||
getListOfParticipants()
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "Error promoting an attendee to moderators", e)
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (participant.type == Participant.ParticipantType.MODERATOR) {
|
||||
ncApi.demoteModeratorToUser(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.userId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
getListOfParticipants()
|
||||
}
|
||||
} else if (participant.type == Participant.ParticipantType.USER) {
|
||||
ncApi.promoteUserToModerator(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoomModerators(
|
||||
apiVersion,
|
||||
conversationUser.baseUrl,
|
||||
conversation!!.token
|
||||
),
|
||||
participant.userId
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
getListOfParticipants()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (index == 1) {
|
||||
if (apiVersion >= ApiUtils.APIv4) {
|
||||
|
Loading…
Reference in New Issue
Block a user