feat: Add acknowledgement status and retry for emoji reactions (#4142)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-06 11:43:36 -06:00 committed by GitHub
parent 41c5992158
commit 2526728859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1257 additions and 83 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.core.database
import android.content.Context
@ -85,8 +84,9 @@ import org.meshtastic.core.database.entity.TracerouteNodePositionEntity
AutoMigration(from = 24, to = 25),
AutoMigration(from = 25, to = 26),
AutoMigration(from = 26, to = 27),
AutoMigration(from = 27, to = 28),
],
version = 27,
version = 28,
exportSchema = true,
)
@TypeConverters(Converters::class)

View file

@ -309,6 +309,11 @@ interface PacketDao {
@Upsert suspend fun insert(reaction: ReactionEntity)
@Update suspend fun update(reaction: ReactionEntity)
@Query("SELECT * FROM reactions WHERE packet_id = :packetId LIMIT 1")
suspend fun getReactionByPacketId(packetId: Int): ReactionEntity?
@Transaction
suspend fun deleteAll() {
deleteAllPackets()

View file

@ -25,6 +25,7 @@ import androidx.room.Relation
import org.meshtastic.core.database.model.Message
import org.meshtastic.core.database.model.Node
import org.meshtastic.core.model.DataPacket
import org.meshtastic.core.model.MessageStatus
import org.meshtastic.core.model.util.getShortDateTime
import org.meshtastic.proto.MeshProtos.User
@ -130,12 +131,20 @@ data class Reaction(
val snr: Float,
val rssi: Int,
val hopsAway: Int,
val packetId: Int = 0,
val status: MessageStatus = MessageStatus.UNKNOWN,
val routingError: Int = 0,
val retryCount: Int = 0,
val relays: Int = 0,
val relayNode: Int? = null,
val to: String? = null,
val channel: Int = 0,
)
@Entity(
tableName = "reactions",
primaryKeys = ["reply_id", "user_id", "emoji"],
indices = [Index(value = ["reply_id"])],
indices = [Index(value = ["reply_id"]), Index(value = ["packet_id"])],
)
data class ReactionEntity(
@ColumnInfo(name = "reply_id") val replyId: Int,
@ -145,6 +154,14 @@ data class ReactionEntity(
@ColumnInfo(name = "snr", defaultValue = "0") val snr: Float = 0f,
@ColumnInfo(name = "rssi", defaultValue = "0") val rssi: Int = 0,
@ColumnInfo(name = "hopsAway", defaultValue = "-1") val hopsAway: Int = -1,
@ColumnInfo(name = "packet_id", defaultValue = "0") val packetId: Int = 0,
@ColumnInfo(name = "status", defaultValue = "0") val status: MessageStatus = MessageStatus.UNKNOWN,
@ColumnInfo(name = "routing_error", defaultValue = "0") val routingError: Int = 0,
@ColumnInfo(name = "retry_count", defaultValue = "0") val retryCount: Int = 0,
@ColumnInfo(name = "relays", defaultValue = "0") val relays: Int = 0,
@ColumnInfo(name = "relay_node") val relayNode: Int? = null,
@ColumnInfo(name = "to") val to: String? = null,
@ColumnInfo(name = "channel", defaultValue = "0") val channel: Int = 0,
)
private suspend fun ReactionEntity.toReaction(getNode: suspend (userId: String?) -> Node) = Reaction(
@ -155,6 +172,14 @@ private suspend fun ReactionEntity.toReaction(getNode: suspend (userId: String?)
snr = snr,
rssi = rssi,
hopsAway = hopsAway,
packetId = packetId,
status = status,
routingError = routingError,
retryCount = retryCount,
relays = relays,
relayNode = relayNode,
to = to,
channel = channel,
)
private suspend fun List<ReactionEntity>.toReaction(getNode: suspend (userId: String?) -> Node) =