mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-02 20:53:09 +00:00
add check if delete message is allowed to be executed
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
cc6f582ee2
commit
7cf18923b5
@ -2513,50 +2513,60 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun deleteMessage(message: IMessage?) {
|
fun deleteMessage(message: IMessage?) {
|
||||||
var apiVersion = 1
|
if (!AttendeePermissionsUtil(currentConversation!!.permissions)
|
||||||
// FIXME Fix API checking with guests?
|
.canPostChatShareItemsDoReaction(conversationUser!!)
|
||||||
if (conversationUser != null) {
|
) {
|
||||||
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
Log.e(
|
||||||
}
|
TAG, "Deletion of message is skipped because of restrictions by permissions. " +
|
||||||
|
"This method should not have been called!"
|
||||||
ncApi?.deleteChatMessage(
|
|
||||||
credentials,
|
|
||||||
ApiUtils.getUrlForChatMessage(
|
|
||||||
apiVersion,
|
|
||||||
conversationUser?.baseUrl,
|
|
||||||
roomToken,
|
|
||||||
message?.id
|
|
||||||
)
|
)
|
||||||
)?.subscribeOn(Schedulers.io())
|
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
} else {
|
||||||
?.subscribe(object : Observer<ChatOverallSingleMessage> {
|
var apiVersion = 1
|
||||||
override fun onSubscribe(d: Disposable) {
|
// FIXME Fix API checking with guests?
|
||||||
// unused atm
|
if (conversationUser != null) {
|
||||||
}
|
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||||
|
}
|
||||||
|
|
||||||
override fun onNext(t: ChatOverallSingleMessage) {
|
ncApi?.deleteChatMessage(
|
||||||
if (t.ocs.meta.statusCode == HttpURLConnection.HTTP_ACCEPTED) {
|
credentials,
|
||||||
Toast.makeText(
|
ApiUtils.getUrlForChatMessage(
|
||||||
context, R.string.nc_delete_message_leaked_to_matterbridge,
|
apiVersion,
|
||||||
Toast.LENGTH_LONG
|
conversationUser?.baseUrl,
|
||||||
).show()
|
roomToken,
|
||||||
|
message?.id
|
||||||
|
)
|
||||||
|
)?.subscribeOn(Schedulers.io())
|
||||||
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
?.subscribe(object : Observer<ChatOverallSingleMessage> {
|
||||||
|
override fun onSubscribe(d: Disposable) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onNext(t: ChatOverallSingleMessage) {
|
||||||
Log.e(
|
if (t.ocs.meta.statusCode == HttpURLConnection.HTTP_ACCEPTED) {
|
||||||
TAG,
|
Toast.makeText(
|
||||||
"Something went wrong when trying to delete message with id " +
|
context, R.string.nc_delete_message_leaked_to_matterbridge,
|
||||||
message?.id,
|
Toast.LENGTH_LONG
|
||||||
e
|
).show()
|
||||||
)
|
}
|
||||||
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onError(e: Throwable) {
|
||||||
// unused atm
|
Log.e(
|
||||||
}
|
TAG,
|
||||||
})
|
"Something went wrong when trying to delete message with id " +
|
||||||
|
message?.id,
|
||||||
|
e
|
||||||
|
)
|
||||||
|
Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun replyPrivately(message: IMessage?) {
|
fun replyPrivately(message: IMessage?) {
|
||||||
|
@ -34,7 +34,7 @@ class AttendeePermissionsUtil(flag: Int) {
|
|||||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "chat-permission")) {
|
if (CapabilitiesUtil.hasSpreedFeatureCapability(user, "chat-permission")) {
|
||||||
return canPostChatShareItemsDoReaction
|
return canPostChatShareItemsDoReaction
|
||||||
}
|
}
|
||||||
// if capability is not available the spreed version doesn't support to restrict this
|
// if capability is not available then the spreed version doesn't support to restrict this
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user