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,9 +113,14 @@ class ChatRoomPresenter @Inject constructor( ...@@ -113,9 +113,14 @@ 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) {
try {
chatRoles = if (roomTypeOf(roomType) !is RoomType.DirectMessage) { chatRoles = if (roomTypeOf(roomType) !is RoomType.DirectMessage) {
client.chatRoomRoles(roomType = roomTypeOf(roomType), roomName = roomName) client.chatRoomRoles(roomType = roomTypeOf(roomType), roomName = roomName)
} else emptyList() } else emptyList()
} catch (ex: RocketChatException) {
Timber.e(ex)
chatRoles = emptyList()
} finally {
// User has at least an 'owner' or 'moderator' role. // User has at least an 'owner' or 'moderator' role.
val userCanMod = isOwnerOrMod() val userCanMod = isOwnerOrMod()
// Can post anyway if has the 'post-readonly' permission on server. // Can post anyway if has the 'post-readonly' permission on server.
...@@ -131,6 +136,7 @@ class ChatRoomPresenter @Inject constructor( ...@@ -131,6 +136,7 @@ class ChatRoomPresenter @Inject constructor(
} }
} }
} }
}
private fun isOwnerOrMod(): Boolean { private fun isOwnerOrMod(): Boolean {
return chatRoles.firstOrNull { it.user.username == currentLoggedUsername }?.roles?.any { return chatRoles.firstOrNull { it.user.username == currentLoggedUsername }?.roles?.any {
......
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