From 7ec35db6c9f623798aaae5498b7491936616ecf1 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 7 Sep 2024 23:24:49 +0200 Subject: [PATCH] Include tickets to trusted peers --- sbapp/sideband/core.py | 9 +++++---- sbapp/ui/objectdetails.py | 11 +---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index c350d94..fc57aec 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -1229,7 +1229,7 @@ class SidebandCore(): {Commands.TELEMETRY_REQUEST: request_timebase}, ]} - lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields) + lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields, include_ticket=True) lxm.request_timebase = request_timebase lxm.register_delivery_callback(self.telemetry_request_finished) lxm.register_failed_callback(self.telemetry_request_finished) @@ -1296,7 +1296,7 @@ class SidebandCore(): telemetry_timebase = max(telemetry_timebase, ts) if telemetry_timebase > (self.getpersistent(f"telemetry.{RNS.hexrep(to_addr, delimit=False)}.last_send_success_timebase") or 0): - lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields) + lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields, include_ticket=self.is_trusted(to_addr)) lxm.telemetry_timebase = telemetry_timebase lxm.register_delivery_callback(self.outbound_telemetry_finished) lxm.register_failed_callback(self.outbound_telemetry_finished) @@ -3726,6 +3726,7 @@ class SidebandCore(): source = self.lxmf_destination desired_method = LXMF.LXMessage.PAPER + # TODO: Should paper messages also include a ticket to trusted peers? lxm = LXMF.LXMessage(dest, source, content, title="", desired_method=desired_method, fields = self.get_message_fields(destination_hash)) self.lxm_ingest(lxm, originator=True) @@ -3776,7 +3777,7 @@ class SidebandCore(): if audio != None: fields[LXMF.FIELD_AUDIO] = audio - lxm = LXMF.LXMessage(dest, source, content, title="", desired_method=desired_method, fields = fields) + lxm = LXMF.LXMessage(dest, source, content, title="", desired_method=desired_method, fields = fields, include_ticket=self.is_trusted(destination_hash)) if not no_display: lxm.register_delivery_callback(self.message_notification) @@ -3830,7 +3831,7 @@ class SidebandCore(): else: desired_method = LXMF.LXMessage.DIRECT - lxm = LXMF.LXMessage(dest, source, "", title="", desired_method=desired_method, fields = {LXMF.FIELD_COMMANDS: commands}) + lxm = LXMF.LXMessage(dest, source, "", title="", desired_method=desired_method, fields = {LXMF.FIELD_COMMANDS: commands}, include_ticket=self.is_trusted(destination_hash)) lxm.register_delivery_callback(self.message_notification) lxm.register_failed_callback(self.message_notification) diff --git a/sbapp/ui/objectdetails.py b/sbapp/ui/objectdetails.py index bf592bf..21b619f 100644 --- a/sbapp/ui/objectdetails.py +++ b/sbapp/ui/objectdetails.py @@ -818,7 +818,7 @@ class RVDetails(MDRecycleView): stamp_cost = self.delegate.app.sideband.message_router.get_outbound_stamp_cost(self.delegate.object_hash) t_str = "" if ticket_expires: - t_str = " (but have ticket)" + 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}) if ticket_expires: @@ -828,15 +828,6 @@ class RVDetails(MDRecycleView): except Exception as e: RNS.trace_exception(e) - try: - ticket_expires = self.delegate.app.sideband.message_router.get_outbound_ticket_expiry(self.delegate.object_hash) - 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}) - - except Exception as e: - RNS.trace_exception(e) - if len(self.entries) == 0: self.entries.append({"icon": "timeline-question-outline", "text": f"No telemetry available for this device"})