Integrate Should I Answer? blocking support (#977)

* Pulled over SIA code from 2.7.3

* Eliminate unnecessary service, fix service binding

* Flatten logic in isBlocked

* Return single which emits shouldBlock state

* Mark conversation as blocked during sync
This commit is contained in:
Moez Bhatti
2018-04-04 21:23:41 -04:00
committed by GitHub
parent 17017313cc
commit 0c3fc6c8a7
6 changed files with 186 additions and 0 deletions
@@ -38,6 +38,7 @@ import io.reactivex.schedulers.Schedulers
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
import manager.ExternalBlockingManager
import manager.KeyManager
import mapper.CursorToConversation
import mapper.CursorToRecipient
@@ -61,6 +62,7 @@ class MessageRepositoryImpl @Inject constructor(
private val messageIds: KeyManager,
private val cursorToConversation: CursorToConversation,
private val cursorToRecipient: CursorToRecipient,
private val externalBlockingManager: ExternalBlockingManager,
private val prefs: Preferences) : MessageRepository {
override fun getConversations(archived: Boolean): Flowable<List<Conversation>> {
@@ -624,6 +626,11 @@ class MessageRepositoryImpl @Inject constructor(
}
}
// If any of the addresses here should be blocked, then block the conversation
conversation.blocked = recipients.map { it.address }.any { address ->
externalBlockingManager.shouldBlock(address).blockingGet()
}
conversation.recipients.clear()
conversation.recipients.addAll(recipients)
conversation.insertOrUpdate()