Closed nikdevpub closed 4 years ago
`fun deleteMessage(message: Message, type: ChatMessageAdapter.DeleteType) { if (generalChannel != null) {
val obj = JSONObject()
obj.put("status", "deleted")
if (type == ChatMessageAdapter.DeleteType.Global) {
obj.put("for", "everyone")
} else {
obj.put("for", "patient")
}
viewState.setFileLoading(true)
message.setAttributes(obj, object : StatusListener() {
override fun onSuccess() {
viewState.setFileLoading(false)
viewState.updateMessages()
}
override fun onError(errorInfo: ErrorInfo?) {
super.onError(errorInfo)
viewState.setFileLoading(false)
viewState.showError(context.getString(R.string.chat_deleting_error) + errorInfo.toString())
}
})
}
}`
Hi
Does your user have editAnyMessageAttributes
or editOwnMessageAttributes
permissions enabled?
See this doc for explanation of roles. And use https://www.twilio.com/console/chat/services/<YOUR ISxxx service instance id here>/roles/new/channel
to see full list of permissions.
Your default channel user role should have one of the listed above permissions. Open https://www.twilio.com/console/chat/services/<YOUR ISxxx service instance id here>/roles
to see a list of the roles and click on channel user
role - by default it has editOwnMessageAttributes
permission but not editAnyMessageAttributes
- this is for security so users don't edit other user's messages.
If that's the case - you are probably trying to modify other user's message's attributes.
Closing as apparently resolved.
When changing attributes on IOS, everything works well, but on Android I get an error message: "0:50107 User not authorized for command" com.twilio:chat-android:4.2.0 ` private fun initChatClient(chatData: ChatData) { viewState.setChatData(chatData) Timber.d(chatData.identity) val props = ChatClient.Properties.Builder() .createProperties() Timber.d(chatData.toString()) ChatClient.create( context, chatData.access_token, props, object : CallbackListener() {
override fun onSuccess(chatClient: ChatClient) {
this@ChatPresenter.chatClient = chatClient
loadChannels(chatData.identity)
Timber.d("Success creating Twilio Chat Client")
}
private fun loadMessages() { viewState.setMessageListLoading(true) isNextPageLoading = true
`