Add ability to check blacklist in spite of blacklist schedule

This commit is contained in:
Moez Bhatti
2021-02-10 21:27:06 -05:00
parent 178cccd93f
commit 2bcb05945b
11 changed files with 45 additions and 15 deletions
@@ -77,7 +77,7 @@ class BlockingDialog @Inject constructor(
}
private fun allBlocked(addresses: List<String>): Boolean = addresses.all { address ->
blockingManager.getAction(address).blockingGet() is BlockingClient.Action.Block
blockingManager.isBlacklisted(address).blockingGet() is BlockingClient.Action.Block
}
private suspend fun showDialog(
@@ -92,8 +92,9 @@ class BlockingDialog @Inject constructor(
}
val manager = context.getString(when (prefs.blockingManager.get()) {
Preferences.BLOCKING_MANAGER_SIA -> R.string.blocking_manager_sia_title
Preferences.BLOCKING_MANAGER_CB -> R.string.blocking_manager_call_blocker_title
Preferences.BLOCKING_MANAGER_CC -> R.string.blocking_manager_call_control_title
Preferences.BLOCKING_MANAGER_SIA -> R.string.blocking_manager_sia_title
else -> R.string.blocking_manager_qksms_title
})
@@ -38,8 +38,9 @@ class BlockingPresenter @Inject constructor(
disposables += prefs.blockingManager.asObservable()
.map { client ->
when (client) {
Preferences.BLOCKING_MANAGER_SIA -> R.string.blocking_manager_sia_title
Preferences.BLOCKING_MANAGER_CB -> R.string.blocking_manager_call_blocker_title
Preferences.BLOCKING_MANAGER_CC -> R.string.blocking_manager_call_control_title
Preferences.BLOCKING_MANAGER_SIA -> R.string.blocking_manager_sia_title
else -> R.string.blocking_manager_qksms_title
}
}
@@ -118,7 +118,7 @@ class BlockingManagerPresenter @Inject constructor(
.switchMap { numbers -> callControl.block(numbers).andThen(Observable.just(Unit)) } // Hack
.autoDisposable(view.scope())
.subscribe {
callControl.getAction("callcontrol").blockingGet()
callControl.shouldBlock("callcontrol").blockingGet()
analytics.setUserProperty("Blocking Manager", "Call Control")
prefs.blockingManager.set(Preferences.BLOCKING_MANAGER_CC)
}
@@ -143,6 +143,6 @@ class BlockingManagerPresenter @Inject constructor(
private fun getAddressesToBlock(client: BlockingClient) = conversationRepo.getBlockedConversations()
.fold(listOf<String>(), { numbers, conversation -> numbers + conversation.recipients.map { it.address } })
.filter { number -> client.getAction(number).blockingGet() !is BlockingClient.Action.Block }
.filter { number -> client.isBlacklisted(number).blockingGet() !is BlockingClient.Action.Block }
}