Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
ebe0a78e
Commit
ebe0a78e
authored
Feb 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add checks for permission to delete a message and whether to show or not a deleted message status
parent
7c7f235b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+13
-6
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
ebe0a78e
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
...
@@ -5,6 +5,7 @@ import chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.PermissionsInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.launchUI
import
chat.rocket.android.util.launchUI
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
...
@@ -20,6 +21,7 @@ import chat.rocket.core.internal.rest.sendMessage
...
@@ -20,6 +21,7 @@ import chat.rocket.core.internal.rest.sendMessage
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Value
import
chat.rocket.core.model.Value
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.cancel
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.launch
import
timber.log.Timber
import
timber.log.Timber
...
@@ -29,16 +31,13 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -29,16 +31,13 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
getSettingsInteractor
:
GetSettingsInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
serverInteractor
:
GetCurrentServerInteractor
,
private
val
permissionsInteractor
:
PermissionsInteractor
,
private
val
messagesRepository
:
MessagesRepository
,
private
val
messagesRepository
:
MessagesRepository
,
factory
:
RocketChatClientFactory
,
factory
:
RocketChatClientFactory
,
private
val
mapper
:
MessageViewModelMapper
)
{
private
val
mapper
:
MessageViewModelMapper
)
{
private
val
client
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
private
val
client
=
factory
.
create
(
serverInteractor
.
get
()
!!
)
private
var
subId
:
String
?
=
null
private
var
subId
:
String
?
=
null
private
var
settings
:
Map
<
String
,
Value
<
Any
>>?
=
null
private
var
settings
:
Map
<
String
,
Value
<
Any
>>
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
!!
init
{
settings
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
}
private
val
stateChannel
=
Channel
<
State
>()
private
val
stateChannel
=
Channel
<
State
>()
...
@@ -148,13 +147,21 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
...
@@ -148,13 +147,21 @@ class ChatRoomPresenter @Inject constructor(private val view: ChatRoomView,
*/
*/
fun
deleteMessage
(
roomId
:
String
,
id
:
String
)
{
fun
deleteMessage
(
roomId
:
String
,
id
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
if
(!
permissionsInteractor
.
isMessageDeletingAllowed
())
{
coroutineContext
.
cancel
()
return
@launchUI
}
//TODO: Default delete message always to true. Until we have the permissions system
//TODO: Default delete message always to true. Until we have the permissions system
//implemented, a user will only be able to delete his own messages.
//implemented, a user will only be able to delete his own messages.
try
{
try
{
//TODO: Should honor permission 'Message_ShowDeletedStatus'
//TODO: Should honor permission 'Message_ShowDeletedStatus'
client
.
deleteMessage
(
roomId
,
id
,
true
)
client
.
deleteMessage
(
roomId
,
id
,
true
)
// if Message_ShowDeletedStatus == true an update to that message will be dispatched.
// Otherwise we signalize that we just want the message removed.
if
(!
permissionsInteractor
.
showDeletedStatus
())
{
view
.
dispatchDeleteMessage
(
id
)
}
}
catch
(
e
:
RocketChatException
)
{
}
catch
(
e
:
RocketChatException
)
{
//TODO: Handle permission error.
Timber
.
e
(
e
)
Timber
.
e
(
e
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment