mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat(db): Add sender-based message filtering (#4477)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
d48a0ea2b3
commit
fce8e7cd08
5 changed files with 235 additions and 4 deletions
|
|
@ -344,6 +344,11 @@ constructor(
|
|||
dbManager.currentDb.value.packetDao().migrateChannelsByPSK(oldSettings, newSettings)
|
||||
}
|
||||
|
||||
suspend fun updateFilteredBySender(senderId: String, filtered: Boolean) {
|
||||
val pattern = "%\"from\":\"${senderId}\"%"
|
||||
withContext(dispatchers.io) { dbManager.currentDb.value.packetDao().updateFilteredBySender(pattern, filtered) }
|
||||
}
|
||||
|
||||
private fun org.meshtastic.core.database.dao.PacketDao.getAllWaypointsFlow(): Flow<List<Packet>> =
|
||||
getAllPackets(PortNum.WAYPOINT_APP.value)
|
||||
|
||||
|
|
|
|||
|
|
@ -496,4 +496,10 @@ interface PacketDao {
|
|||
|
||||
@Query("SELECT * FROM packet WHERE port_num = 1")
|
||||
suspend fun getAllUserPacketsForMigration(): List<Packet>
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Query(
|
||||
"UPDATE packet SET filtered = :filtered WHERE (myNodeNum = 0 OR myNodeNum = (SELECT myNodeNum FROM my_node)) AND data LIKE :senderIdPattern",
|
||||
)
|
||||
suspend fun updateFilteredBySender(senderIdPattern: String, filtered: Boolean)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue