Include tickets to trusted peers

This commit is contained in:
Mark Qvist 2024-09-07 23:24:49 +02:00
parent e0e1540a94
commit 7ec35db6c9
2 changed files with 6 additions and 14 deletions

View File

@ -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)

View File

@ -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"})