Commit 4d499f5b authored by Leonardo Aramaki's avatar Leonardo Aramaki

Get a ChatRoom object by its room id

parent 4c6ea9b6
package chat.rocket.android.server.domain
import chat.rocket.core.model.ChatRoom
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.async
import javax.inject.Inject
......@@ -19,4 +20,21 @@ class GetChatRoomsInteractor @Inject constructor(private val repository: ChatRoo
}
return chatRooms.await()
}
/**
* Get a specific room by its id.
*
* @param serverUrl The server url where the room is.
* @param roomId The id of the room to get.
*
* @return The ChatRoom object or null if we couldn't find any.
*/
suspend fun getByRoomId(serverUrl: String, roomId: String): ChatRoom {
return async(CommonPool) {
val allChatRooms = repository.get(serverUrl)
return@async allChatRooms.first {
it.id == roomId
}
}.await()
}
}
\ No newline at end of file
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