fix: properly block MMS messages from unknown numbers (#625)
Refs: https://github.com/FossifyOrg/Messages/issues/610
This commit is contained in:
parent
0cafa22acf
commit
1a804c6473
3 changed files with 15 additions and 13 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
- Fixed new conversation shortcut ([#416])
|
||||
- Fixed blocking MMS messages from unknown numbers ([#610])
|
||||
|
||||
## [1.6.0] - 2025-10-29
|
||||
### Changed
|
||||
|
|
@ -207,6 +208,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#562]: https://github.com/FossifyOrg/Messages/issues/562
|
||||
[#574]: https://github.com/FossifyOrg/Messages/issues/574
|
||||
[#600]: https://github.com/FossifyOrg/Messages/issues/600
|
||||
[#610]: https://github.com/FossifyOrg/Messages/issues/610
|
||||
|
||||
[Unreleased]: https://github.com/FossifyOrg/Messages/compare/1.6.0...HEAD
|
||||
[1.6.0]: https://github.com/FossifyOrg/Messages/compare/1.5.0...1.6.0
|
||||
|
|
|
|||
|
|
@ -29,7 +29,17 @@ class MmsReceiver : MmsReceivedReceiver() {
|
|||
|
||||
override fun isAddressBlocked(context: Context, address: String): Boolean {
|
||||
val normalizedAddress = address.normalizePhoneNumber()
|
||||
return context.isNumberBlocked(normalizedAddress)
|
||||
if (context.isNumberBlocked(normalizedAddress)) return true
|
||||
if (context.baseConfig.blockUnknownNumbers) {
|
||||
val privateCursor = context.getMyContactsCursor(
|
||||
favoritesOnly = false,
|
||||
withPhoneNumbersOnly = true
|
||||
)
|
||||
val isKnownContact = SimpleContactsHelper(context).existsSync(address, privateCursor)
|
||||
return !isKnownContact
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun isContentBlocked(context: Context, content: String): Boolean {
|
||||
|
|
@ -39,22 +49,11 @@ class MmsReceiver : MmsReceivedReceiver() {
|
|||
override fun onMessageReceived(context: Context, messageUri: Uri) {
|
||||
val mms = context.getLatestMMS() ?: return
|
||||
val address = mms.getSender()?.phoneNumbers?.first()?.normalizedNumber ?: ""
|
||||
|
||||
val size = context.resources.getDimension(R.dimen.notification_large_icon_size).toInt()
|
||||
val privateCursor = context.getMyContactsCursor(false, true)
|
||||
ensureBackgroundThread {
|
||||
if (context.baseConfig.blockUnknownNumbers) {
|
||||
val simpleContactsHelper = SimpleContactsHelper(context)
|
||||
simpleContactsHelper.exists(address, privateCursor) { exists ->
|
||||
if (exists) {
|
||||
handleMmsMessage(context, mms, size, address)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
handleMmsMessage(context, mms, size, address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(context: Context, error: String) {
|
||||
context.showErrorToast(context.getString(R.string.couldnt_download_mms))
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
}
|
||||
if (context.baseConfig.blockUnknownNumbers) {
|
||||
val simpleContactsHelper = SimpleContactsHelper(context)
|
||||
// Maybe switch to existsSync()? No?
|
||||
simpleContactsHelper.exists(address, privateCursor) { exists ->
|
||||
if (exists) {
|
||||
handleMessage(context, address, subject, body, date, read, threadId, type, subscriptionId, status)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue