Skip to content

Commit

Permalink
Fixed webchat packets without msgNo
Browse files Browse the repository at this point in the history
This patch makes a fix in the webchat UI for packets that
don't have a msgNo in the RX'd packets.  Previously the packets
would just show up as a dupe of the previous RX'd packet from
the same callsign.  Webchat UI will now properly show the message
by creating a fake msgNo value based on the contents of the RX'd packet
from_call+addressee+message_text
  • Loading branch information
hemna committed Nov 27, 2024
1 parent f66b962 commit d4ae726
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aprsd/cmds/webchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ def on_send(self, data):
pkt.prepare()
self.msg = pkt
msgs = SentMessages()
msgs.add(pkt)
tx.send(pkt)
msgs.add(pkt)
msgs.set_status(pkt.msgNo, "Sending")
obj = msgs.get(pkt.msgNo)
socketio.emit(
Expand Down
19 changes: 19 additions & 0 deletions aprsd/web/chat/static/js/send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,30 @@ function sent_msg(msg) {
reload_popovers();
}

function str_to_int(my_string) {
total = 0
for (let i = 0; i < my_string.length; i++) {
total += my_string.charCodeAt(i);
}
return total
}

function from_msg(msg) {
if (!from_msg_list.hasOwnProperty(msg["from_call"])) {
from_msg_list[msg["from_call"]] = new Array();
}

// Try to account for messages that have no msgNo
console.log(msg)
if (msg["msgNo"] == null) {
console.log("Need to add msgNO!!")
// create an artificial msgNo
total = str_to_int(msg["from_call"])
total += str_to_int(msg["addresse"])
total += str_to_int(msg["message_text"])
msg["msgNo"] = total
}

if (msg["msgNo"] in from_msg_list[msg["from_call"]]) {
// We already have this message
//console.log("We already have this message msgNo=" + msg["msgNo"]);
Expand Down

0 comments on commit d4ae726

Please sign in to comment.