Commit eaaad0d5 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Swallow exception if (channels/groups).roles endpoint does not exists on server

parent 4f175506
...@@ -113,21 +113,27 @@ class ChatRoomPresenter @Inject constructor( ...@@ -113,21 +113,27 @@ class ChatRoomPresenter @Inject constructor(
fun setupChatRoom(roomId: String, roomName: String, roomType: String, chatRoomMessage: String? = null) { fun setupChatRoom(roomId: String, roomName: String, roomType: String, chatRoomMessage: String? = null) {
launchUI(strategy) { launchUI(strategy) {
chatRoles = if (roomTypeOf(roomType) !is RoomType.DirectMessage) { try {
client.chatRoomRoles(roomType = roomTypeOf(roomType), roomName = roomName) chatRoles = if (roomTypeOf(roomType) !is RoomType.DirectMessage) {
} else emptyList() client.chatRoomRoles(roomType = roomTypeOf(roomType), roomName = roomName)
// User has at least an 'owner' or 'moderator' role. } else emptyList()
val userCanMod = isOwnerOrMod() } catch (ex: RocketChatException) {
// Can post anyway if has the 'post-readonly' permission on server. Timber.e(ex)
val userCanPost = userCanMod || permissions.canPostToReadOnlyChannels() chatRoles = emptyList()
chatIsBroadcast = chatRoomsInteractor.getById(currentServer, roomId)?.run { } finally {
broadcast // User has at least an 'owner' or 'moderator' role.
} ?: false val userCanMod = isOwnerOrMod()
view.onRoomUpdated(userCanPost, chatIsBroadcast, userCanMod) // Can post anyway if has the 'post-readonly' permission on server.
loadMessages(roomId, roomType) val userCanPost = userCanMod || permissions.canPostToReadOnlyChannels()
chatRoomMessage?.let { messageHelper.messageIdFromPermalink(it) }?.let { messageId -> chatIsBroadcast = chatRoomsInteractor.getById(currentServer, roomId)?.run {
val name = messageHelper.roomNameFromPermalink(chatRoomMessage) broadcast
citeMessage(name!!, messageHelper.roomTypeFromPermalink(chatRoomMessage)!!, messageId, true) } ?: false
view.onRoomUpdated(userCanPost, chatIsBroadcast, userCanMod)
loadMessages(roomId, roomType)
chatRoomMessage?.let { messageHelper.messageIdFromPermalink(it) }?.let { messageId ->
val name = messageHelper.roomNameFromPermalink(chatRoomMessage)
citeMessage(name!!, messageHelper.roomTypeFromPermalink(chatRoomMessage)!!, messageId, true)
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment