Added ratchet info display to object details

This commit is contained in:
Mark Qvist 2024-09-07 22:29:30 +02:00
parent 5d586d26fc
commit e0e1540a94
4 changed files with 51 additions and 13 deletions

View File

@ -936,6 +936,12 @@ class SidebandApp(MDApp):
if self.conversations_view != None:
self.conversations_view.update()
if self.sideband.getstate("app.flags.new_ticket", allow_cache=True):
def cb(d):
self.sideband.message_router.reload_available_tickets()
self.sideband.setstate("app.flags.new_ticket", False)
Clock.schedule_once(cb, 1.5)
if self.sideband.getstate("wants.viewupdate.conversations", allow_cache=True):
if self.conversations_view != None:
self.conversations_view.update()

View File

@ -3647,14 +3647,20 @@ class SidebandCore():
def message_notification(self, message, no_display=False):
if message.state == LXMF.LXMessage.FAILED and hasattr(message, "try_propagation_on_fail") and message.try_propagation_on_fail:
RNS.log("Direct delivery of "+str(message)+" failed. Retrying as propagated message.", RNS.LOG_VERBOSE)
message.try_propagation_on_fail = None
message.delivery_attempts = 0
del message.next_delivery_attempt
message.packed = None
message.desired_method = LXMF.LXMessage.PROPAGATED
self._db_message_set_method(message.hash, LXMF.LXMessage.PROPAGATED)
self.message_router.handle_outbound(message)
if hasattr(message, "stamp_generation_failed") and message.stamp_generation_failed == True:
RNS.log(f"Could not send {message} due to a stamp generation failure", RNS.LOG_ERROR)
if not no_display:
self.lxm_ingest(message, originator=True)
else:
RNS.log("Direct delivery of "+str(message)+" failed. Retrying as propagated message.", RNS.LOG_VERBOSE)
message.try_propagation_on_fail = None
message.delivery_attempts = 0
if hasattr(message, "next_delivery_attempt"):
del message.next_delivery_attempt
message.packed = None
message.desired_method = LXMF.LXMessage.PROPAGATED
self._db_message_set_method(message.hash, LXMF.LXMessage.PROPAGATED)
self.message_router.handle_outbound(message)
else:
if not no_display:
self.lxm_ingest(message, originator=True)
@ -3771,9 +3777,6 @@ class SidebandCore():
fields[LXMF.FIELD_AUDIO] = audio
lxm = LXMF.LXMessage(dest, source, content, title="", desired_method=desired_method, fields = fields)
# Defer stamp generation so workload doesn't run on UI thread
lxm.defer_stamp = True
if not no_display:
lxm.register_delivery_callback(self.message_notification)
@ -3926,6 +3929,11 @@ class SidebandCore():
RNS.log("Squelching notification due to telemetry-only message", RNS.LOG_DEBUG)
telemetry_only = True
if LXMF.FIELD_TICKET in message.fields:
if self.is_service:
RNS.log("Notifying UI of newly arrived delivery ticket", RNS.LOG_DEBUG)
self.setstate("app.flags.new_ticket", True)
if not telemetry_only:
if self._db_conversation(context_dest) == None:
self._db_create_conversation(context_dest)

View File

@ -160,7 +160,7 @@ class Messages():
if prg <= 0.00:
stamp_cost = self.app.sideband.get_lxm_stamp_cost(msg["hash"])
if stamp_cost:
sphrase = f"Generating stamp (cost {stamp_cost})"
sphrase = f"Generating stamp with cost {stamp_cost}"
prgstr = ""
else:
sphrase = "Waiting for path"

View File

@ -781,6 +781,14 @@ class RVDetails(MDRecycleView):
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.trace_exception(e)
try:
ratchet_id = RNS.Identity.current_ratchet_id(self.delegate.object_hash)
if ratchet_id:
self.entries.append({"icon": "lock-check-outline", "text": f"Using ratchet [b]{RNS.prettyhexrep(ratchet_id)}[/b]", "on_release": pass_job})
except Exception as e:
RNS.trace_exception(e)
try:
nh = RNS.Transport.hops_to(self.delegate.object_hash)
nhi = self.delegate.app.sideband.reticulum.get_next_hop_if_name(self.delegate.object_hash)
@ -806,9 +814,25 @@ class RVDetails(MDRecycleView):
RNS.trace_exception(e)
try:
ticket_expires = self.delegate.app.sideband.message_router.get_outbound_ticket_expiry(self.delegate.object_hash)
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)"
if stamp_cost:
self.entries.append({"icon": "postage-stamp", "text": f"Required stamp cost [b]{stamp_cost}[/b]", "on_release": pass_job})
self.entries.append({"icon": "postage-stamp", "text": f"Required stamp cost [b]{stamp_cost}[/b]"+t_str, "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})
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)