Don't unblock numbers not reported by SIA

This commit is contained in:
moezbhatti
2019-08-30 16:54:05 +02:00
parent 03af81336c
commit e1b1a6c8db
11 changed files with 69 additions and 66 deletions
@@ -57,19 +57,19 @@ class ReceiveMms @Inject constructor(
// to check if it should be blocked after we've pulled it into realm. If it
// turns out that it should be dropped, then delete it
// TODO Don't store blocked messages in the first place
val shouldBlock = blockingClient.isBlocked(message.address).blockingGet()
val action = blockingClient.getAction(message.address).blockingGet()
val shouldDrop = prefs.drop.get()
Timber.v("block=$shouldBlock, drop=$shouldDrop")
Timber.v("block=$action, drop=$shouldDrop")
if (shouldBlock && shouldDrop) {
if (action == BlockingClient.Action.BLOCK && shouldDrop) {
messageRepo.deleteMessages(message.id)
return@mapNotNull null
}
if (shouldBlock) {
conversationRepo.markBlocked(message.threadId)
} else {
conversationRepo.markUnblocked(message.threadId)
when (action) {
BlockingClient.Action.BLOCK -> conversationRepo.markBlocked(message.threadId)
BlockingClient.Action.UNBLOCK -> conversationRepo.markUnblocked(message.threadId)
else -> Unit
}
message
@@ -49,12 +49,12 @@ class ReceiveSms @Inject constructor(
// Don't continue if the sender is blocked
val messages = it.messages
val address = messages[0].displayOriginatingAddress
val shouldBlock = blockingClient.isBlocked(address).blockingGet()
val action = blockingClient.getAction(address).blockingGet()
val shouldDrop = prefs.drop.get()
Timber.v("block=$shouldBlock, drop=$shouldDrop")
Timber.v("block=$action, drop=$shouldDrop")
// If we should drop the message, don't even save it
if (shouldBlock && shouldDrop) {
if (action == BlockingClient.Action.BLOCK && shouldDrop) {
return@mapNotNull null
}
@@ -66,10 +66,10 @@ class ReceiveSms @Inject constructor(
// Add the message to the db
val message = messageRepo.insertReceivedSms(it.subId, address, body, time)
if (shouldBlock) {
conversationRepo.markBlocked(message.threadId)
} else {
conversationRepo.markUnblocked(message.threadId)
when (action) {
BlockingClient.Action.BLOCK -> conversationRepo.markBlocked(message.threadId)
BlockingClient.Action.UNBLOCK -> conversationRepo.markUnblocked(message.threadId)
else -> Unit
}
message