diff --git a/sbapp/main.py b/sbapp/main.py index b85232c..a325992 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -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() diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 40ca65c..c350d94 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -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) diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index e0cb096..7b5f5a9 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -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" diff --git a/sbapp/ui/objectdetails.py b/sbapp/ui/objectdetails.py index 0dd1255..bf592bf 100644 --- a/sbapp/ui/objectdetails.py +++ b/sbapp/ui/objectdetails.py @@ -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)