From c6f82a917d66c444dda7a0a1bc0c44708bea6749 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 8 Sep 2024 01:20:52 +0200 Subject: [PATCH] Save and display stamp status on messages --- sbapp/sideband/core.py | 10 +++++++++- sbapp/ui/messages.py | 8 ++++++++ sbapp/ui/objectdetails.py | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index fc57aec..0e9191b 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -2606,6 +2606,14 @@ class SidebandCore(): extras["snr"] = lxm.snr extras["q"] = lxm.q + if lxm.stamp_checked: + extras["stamp_checked"] = True + extras["stamp_valid"] = lxm.stamp_valid + extras["stamp_value"] = lxm.stamp_value + + if lxm.ratchet_id: + extras["ratchet_id"] = lxm.ratchet_id + if packed_telemetry != None: extras["packed_telemetry"] = packed_telemetry @@ -2671,7 +2679,7 @@ class SidebandCore(): def lxmf_announce(self, attached_interface=None): if self.is_standalone or self.is_service: if self.config["lxmf_require_stamps"]: - self.message_router.set_inbound_stamp_cost(self.lxmf_destination, self.config["lxmf_inbound_stamp_cost"]) + self.message_router.set_inbound_stamp_cost(self.lxmf_destination.hash, self.config["lxmf_inbound_stamp_cost"]) self.message_router.announce(self.lxmf_destination.hash, attached_interface=attached_interface) else: self.lxmf_destination.announce(attached_interface=attached_interface) diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index 7b5f5a9..4457440 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -280,6 +280,8 @@ class Messages(): has_attachment = False force_markup = False signature_valid = False + stamp_valid = False + stamp_value = None if "lxm" in m and m["lxm"] != None and m["lxm"].signature_validated: signature_valid = True @@ -290,6 +292,10 @@ class Messages(): except Exception as e: pass + if "extras" in m and m["extras"] != None and "stamp_checked" in m["extras"] and m["extras"]["stamp_checked"] == True: + stamp_valid = m["extras"]["stamp_valid"] + stamp_value = m["extras"]["stamp_value"] + if "lxm" in m and m["lxm"] != None and m["lxm"].fields != None and LXMF.FIELD_COMMANDS in m["lxm"].fields: try: commands = m["lxm"].fields[LXMF.FIELD_COMMANDS] @@ -409,6 +415,8 @@ class Messages(): heading_str = titlestr if phy_stats_str != "" and self.app.sideband.config["advanced_stats"]: heading_str += phy_stats_str+"\n" + if stamp_valid: + txstr += f" [b]Stamp[/b] value is {stamp_value} " heading_str += "[b]Sent[/b] "+txstr heading_str += "\n[b]Received[/b] "+rxstr diff --git a/sbapp/ui/objectdetails.py b/sbapp/ui/objectdetails.py index 21b619f..6acb51f 100644 --- a/sbapp/ui/objectdetails.py +++ b/sbapp/ui/objectdetails.py @@ -821,6 +821,8 @@ class RVDetails(MDRecycleView): t_str = ", but have ticket" if stamp_cost: self.entries.append({"icon": "postage-stamp", "text": f"Required stamp cost [b]{stamp_cost}[/b]"+t_str, "on_release": pass_job}) + else: + self.entries.append({"icon": "postage-stamp", "text": f"No required stamp cost", "on_release": pass_job}) if ticket_expires: valid_for = ticket_expires - time.time() self.entries.append({"icon": "ticket-confirmation", "text": f"Delivery ticket valid for [b]{RNS.prettytime(valid_for)}[/b]", "on_release": pass_job})