Messages icon indicating copy to clipboard operation
Messages copied to clipboard

[FEATURE] Stored/known contacts ignore blocked keywords

Open sudoshindo opened this issue 1 year ago • 4 comments

Checklist

  • [X] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • [X] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • [X] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • [X] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • [X] This issue contains only one feature request.
  • [X] I have read and understood the contribution guidelines.
  • [ ] I optionally donated to support the Fossify mission.

Feature description

New checkbox/toggle in settings labeled "Stored contacts ignore blocked keywords" (tentative)

Behavior:

If enabled, only apply keyword blocking to not stored contacts.

If disabled, apply keyword blocking globally (this is the default behavior).

Why do you want this feature?

More fine tuned control over keyword blocking.

Additional information

⚠️ TREAT THIS AS PSEUDO-CODE ⚠️ ⚠️ THIS IS UNTESTED, I'VE NEVER CODED FOR ANDROID ⚠️

I don't have a Kotlin development environment. I just did this to increase the chances of getting accepted/implemented.

SmsReceiver.kt

// I DON'T KNOW HOW/WHERE TO PROPERLY DECLARE THIS VARIABLE
context.baseConfig.knownNumbersIgnoreKeywords = false

private fun isMessageFilteredOut(context: Context, body: String): Boolean {
    val simpleContactsHelper = SimpleContactsHelper(context)
    simpleContactsHelper.exists(address, privateCursor) { exists ->

        // don't filter if sender is known and setting is enabled
        if (exists && context.baseConfig.knownNumbersIgnoreKeywords) {
            return false
        }

    }

    // resume original function behavior
    for (blockedKeyword in context.config.blockedKeywords) {
        if (body.contains(blockedKeyword, ignoreCase = true)) {
            return true
        }
    }

    return false
}

sudoshindo avatar Jun 07 '24 14:06 sudoshindo

Updated sample code, less confusing if-statement structure. Updated text in "Additional information" section.

sudoshindo avatar Jun 07 '24 19:06 sudoshindo

the fact that messages from my contacts are blocked because they match a keyword is baffling to me. I don't want messages from contacts blocked, it makes the keyword list almost useless. In other words: +1 for this feature.

tve avatar Jun 17 '24 06:06 tve

I have no idea how this will affect alphanumeric Sender IDs though. Like when you receive a message from your network provider and the sender isn't a number but it automatically has its own name even if it's not a saved in your contacts.

IDK if Android treats that as known or unknown.

sudoshindo avatar Jun 17 '24 06:06 sudoshindo

Can I get some feedback on this please?

sudoshindo avatar Oct 06 '24 23:10 sudoshindo