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
c765ed8e
Commit
c765ed8e
authored
May 15, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly check if user has owner or moderator roles at channels
parent
64762358
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+5
-4
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+1
-1
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+4
-8
No files found.
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
c765ed8e
...
...
@@ -116,11 +116,12 @@ class ChatRoomPresenter @Inject constructor(
chatRoles
=
if
(
roomTypeOf
(
roomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
roomType
),
roomName
=
roomName
)
}
else
emptyList
()
val
canPost
=
isOwnerOrMod
()
||
permissions
.
canPostToReadOnlyChannels
()
val
userCanMod
=
isOwnerOrMod
()
val
userCanPost
=
userCanMod
||
permissions
.
canPostToReadOnlyChannels
()
chatIsBroadcast
=
chatRoomsInteractor
.
getById
(
currentServer
,
roomId
)
?.
run
{
broadcast
}
?:
false
view
.
onRoomUpdated
(
canPost
,
chatIsBroadcast
)
view
.
onRoomUpdated
(
userCanPost
,
chatIsBroadcast
,
userCanMod
)
loadMessages
(
roomId
,
roomType
)
chatRoomMessage
?.
let
{
messageHelper
.
messageIdFromPermalink
(
it
)
}
?.
let
{
messageId
->
val
name
=
messageHelper
.
roomNameFromPermalink
(
chatRoomMessage
)
...
...
@@ -130,9 +131,9 @@ class ChatRoomPresenter @Inject constructor(
}
private
fun
isOwnerOrMod
():
Boolean
{
return
chatRoles
.
firstOrNull
{
it
.
user
.
username
==
currentLoggedUsername
}
?.
roles
?.
firstOrNull
{
return
chatRoles
.
firstOrNull
{
it
.
user
.
username
==
currentLoggedUsername
}
?.
roles
?.
any
{
it
==
"owner"
||
it
==
"moderator"
}
?:
false
==
true
}
?:
false
}
fun
loadMessages
(
chatRoomId
:
String
,
chatRoomType
:
String
,
offset
:
Long
=
0
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
c765ed8e
...
...
@@ -139,7 +139,7 @@ interface ChatRoomView : LoadingView, MessageView {
/**
* Communicate whether it's a broadcast channel and if current user can post to it.
*/
fun
onRoomUpdated
(
canPost
:
Boolean
,
broadcastChannel
:
Boolean
)
fun
onRoomUpdated
(
userCanPost
:
Boolean
,
channelIsBroadcast
:
Boolean
,
userIsModerator
:
Boolean
)
/**
* Open a DM with the user in the given [chatRoom] and pass the [permalink] for the message
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
c765ed8e
...
...
@@ -284,10 +284,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onRoomUpdated
(
canPost
:
Boolean
,
broadcastChannel
:
Boolean
)
{
setupMessageComposer
(
isChatRoomOwner
||
c
anPost
)
isBroadcastChannel
=
broadcastChannel
if
(
isBroadcastChannel
)
activity
?.
invalidateOptionsMenu
()
override
fun
onRoomUpdated
(
userCanPost
:
Boolean
,
channelIsBroadcast
:
Boolean
,
userCanMod
:
Boolean
)
{
setupMessageComposer
(
isChatRoomOwner
||
userC
anPost
)
isBroadcastChannel
=
channelIsBroadcast
if
(
isBroadcastChannel
&&
!
userCanMod
)
activity
?.
invalidateOptionsMenu
()
}
override
fun
openDirectMessage
(
chatRoom
:
ChatRoom
,
permalink
:
String
)
{
...
...
@@ -660,10 +660,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
button_join_chat
.
setVisible
(
true
)
button_join_chat
.
setOnClickListener
{
presenter
.
joinChat
(
chatRoomId
)
}
}
else
{
// if (chatRoomMessage.orEmpty().isNotEmpty()) {
// text_message.textContent = chatRoomMessage!!
// text_message.setSelection(chatRoomMessage!!.length)
// }
button_send
.
alpha
=
0f
button_send
.
setVisible
(
false
)
button_show_attachment_options
.
alpha
=
1f
...
...
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