sforkowany z mirror/meshtastic-android
feat: enforce waypoints locked_to
rodzic
a0935a695c
commit
1fc99b8bb4
|
@ -574,27 +574,21 @@ class MeshService : Service(), Logging {
|
|||
}
|
||||
|
||||
private fun rememberDataPacket(dataPacket: DataPacket) {
|
||||
// Now that we use data packets for more things, we need to be choosier about what we keep. Since (currently - in the future less so)
|
||||
// we only care about old text messages, we just store those...
|
||||
if (dataPacket.dataType == Portnums.PortNum.WAYPOINT_APP_VALUE
|
||||
|| dataPacket.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE
|
||||
) {
|
||||
val fromLocal = dataPacket.from == DataPacket.ID_LOCAL
|
||||
val toBroadcast = dataPacket.to == DataPacket.ID_BROADCAST
|
||||
val contactId = if (fromLocal || toBroadcast) dataPacket.to else dataPacket.from
|
||||
val fromLocal = dataPacket.from == DataPacket.ID_LOCAL
|
||||
val toBroadcast = dataPacket.to == DataPacket.ID_BROADCAST
|
||||
val contactId = if (fromLocal || toBroadcast) dataPacket.to else dataPacket.from
|
||||
|
||||
// contactKey: unique contact key filter (channel)+(nodeId)
|
||||
val contactKey = "${dataPacket.channel}$contactId"
|
||||
// contactKey: unique contact key filter (channel)+(nodeId)
|
||||
val contactKey = "${dataPacket.channel}$contactId"
|
||||
|
||||
val packetToSave = Packet(
|
||||
0L, // autoGenerated
|
||||
dataPacket.dataType,
|
||||
contactKey,
|
||||
System.currentTimeMillis(),
|
||||
dataPacket
|
||||
)
|
||||
insertPacket(packetToSave)
|
||||
}
|
||||
val packetToSave = Packet(
|
||||
0L, // autoGenerated
|
||||
dataPacket.dataType,
|
||||
contactKey,
|
||||
System.currentTimeMillis(),
|
||||
dataPacket
|
||||
)
|
||||
insertPacket(packetToSave)
|
||||
}
|
||||
|
||||
/// Update our model and resend as needed for a MeshPacket we just received from the radio
|
||||
|
@ -613,7 +607,6 @@ class MeshService : Service(), Logging {
|
|||
debug("Received data from $fromId, portnum=${data.portnum} ${bytes.size} bytes")
|
||||
|
||||
dataPacket.status = MessageStatus.RECEIVED
|
||||
rememberDataPacket(dataPacket)
|
||||
|
||||
// if (p.hasUser()) handleReceivedUser(fromNum, p.user)
|
||||
|
||||
|
@ -624,9 +617,17 @@ class MeshService : Service(), Logging {
|
|||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE ->
|
||||
if (!fromUs) {
|
||||
debug("Received CLEAR_TEXT from $fromId")
|
||||
rememberDataPacket(dataPacket)
|
||||
updateMessageNotification(dataPacket)
|
||||
}
|
||||
|
||||
Portnums.PortNum.WAYPOINT_APP_VALUE -> {
|
||||
val u = MeshProtos.Waypoint.parseFrom(data.payload)
|
||||
// Validate locked Waypoints from the original sender
|
||||
if (u.lockedTo != 0 && u.lockedTo != packet.from) return
|
||||
rememberDataPacket(dataPacket)
|
||||
}
|
||||
|
||||
// Handle new style position info
|
||||
Portnums.PortNum.POSITION_APP_VALUE -> {
|
||||
var u = MeshProtos.Position.parseFrom(data.payload)
|
||||
|
|
Ładowanie…
Reference in New Issue