feat(db): Add sender-based message filtering (#4477)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-02-06 09:13:59 -06:00 committed by GitHub
parent d48a0ea2b3
commit fce8e7cd08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 235 additions and 4 deletions

View file

@ -105,14 +105,16 @@ constructor(
private fun handleIgnore(action: ServiceAction.Ignore, myNodeNum: Int) {
val node = action.node
val newIgnoredStatus = !node.isIgnored
commandSender.sendAdmin(myNodeNum) {
if (node.isIgnored) {
AdminMessage(remove_ignored_node = node.num)
} else {
if (newIgnoredStatus) {
AdminMessage(set_ignored_node = node.num)
} else {
AdminMessage(remove_ignored_node = node.num)
}
}
nodeManager.updateNodeInfo(node.num) { it.isIgnored = !node.isIgnored }
nodeManager.updateNodeInfo(node.num) { it.isIgnored = newIgnoredStatus }
scope.handledLaunch { packetRepository.get().updateFilteredBySender(node.user.id, newIgnoredStatus) }
}
private fun handleMute(action: ServiceAction.Mute, myNodeNum: Int) {

View file

@ -702,7 +702,11 @@ constructor(
}
}
@Suppress("ReturnCount")
private suspend fun PacketRepository.shouldFilterMessage(dataPacket: DataPacket, contactKey: String): Boolean {
val isIgnored = nodeManager.nodeDBbyID[dataPacket.from]?.isIgnored == true
if (isIgnored) return true
if (dataPacket.dataType != PortNum.TEXT_MESSAGE_APP.value) return false
val isFilteringDisabled = getContactSettings(contactKey).filteringDisabled
return messageFilterService.shouldFilter(dataPacket.text.orEmpty(), isFilteringDisabled)