Commit 0859ad08 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Implement PermissionsInteractor

parent 11df887f
...@@ -223,4 +223,10 @@ class AppModule { ...@@ -223,4 +223,10 @@ class AppModule {
fun provideMessageParser(context: Application, configuration: SpannableConfiguration): MessageParser { fun provideMessageParser(context: Application, configuration: SpannableConfiguration): MessageParser {
return MessageParser(context, configuration) return MessageParser(context, configuration)
} }
@Provides
@Singleton
fun providePermissionInteractor(settingsRepository: SettingsRepository, serverRepository: CurrentServerRepository): PermissionsInteractor {
return PermissionsInteractor(settingsRepository, serverRepository)
}
} }
\ No newline at end of file
package chat.rocket.android.server.domain
import javax.inject.Inject
class PermissionsInteractor @Inject constructor(private val settingsRepository: SettingsRepository,
private val currentServerRepository: CurrentServerRepository) {
private fun publicSettings(): PublicSettings? = settingsRepository.get(currentServerRepository.get()!!)
/**
* Check whether user is allowed to delete a message.
*/
fun isMessageDeletingAllowed() = publicSettings()?.deleteMessageAllowed() ?: false
/**
* Checks whether user is allowed to edit a message.
*/
fun isMessageEditingAllowed() = publicSettings()?.deleteMessageAllowed() ?: false
/**
* Checks whether should show deleted message status.
*/
fun showDeletedStatus() = publicSettings()?.showDeletedStatus() ?: false
/**
* Checks whether should show edited message status.
*/
fun showEditedStatus() = publicSettings()?.showEditedStatus() ?: false
}
\ 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