Fixed call log saving when identity could not be resolved

This commit is contained in:
Mark Qvist 2025-11-10 02:13:14 +01:00
commit 5b1c910f1f
3 changed files with 35 additions and 32 deletions

View file

@ -5583,15 +5583,15 @@ class SidebandCore():
def incoming_call(self, remote_identity):
display_name = self.voice_display_name(remote_identity.hash)
self.setstate("voice.incoming_call", display_name)
if self.gui_foreground(): RNS.log("Squelching call notification since GUI is in foreground", RNS.LOG_DEBUG)
else: self.notify(title="Incoming voice call", content=f"From {display_name}", group="LXST.Telephony", context_id="incoming_call")
if self.gui_foreground() and self.getstate("app.displaying") == "voice_screen": RNS.log("Squelching call notification since voice screen is active", RNS.LOG_DEBUG)
else: self.notify(title="Incoming call", content=f"From {display_name}", group="lxst.telephony.call", context_id="incoming_call")
def missed_call(self, remote_identity):
display_name = self.voice_display_name(remote_identity.hash)
self.setstate("voice.incoming_call", display_name)
self.setstate("voice.missed_call", display_name)
# if self.gui_foreground(): RNS.log("Squelching call notification since GUI is in foreground", RNS.LOG_DEBUG)
# else: self.notify(title="Missed voice call", content=f"From {display_name}", group="LXST.Telephony", context_id="incoming_call")
self.notify(title="Missed voice call", content=f"From {display_name}", group="LXST.Telephony", context_id="incoming_call")
self.notify(title="Missed call", content=f"From {display_name}", group="lxst.telephony.call", context_id="incoming_call")
rns_config = """# This template is used to generate a
# running configuration for Sideband's

View file

@ -136,35 +136,36 @@ class ReticulumTelephone():
return self.call_log
def log_call(self, event, identity):
RNS.log(f"Logging call event {event} for {RNS.prettyhexrep(identity.hash)}", RNS.LOG_DEBUG)
if self.logpath:
try:
if not os.path.isfile(self.logpath):
try:
with open(self.logpath, "wb") as logfile: logfile.write(msgpack.packb([]))
except Exception as e: raise OSError("Could not create call log file")
call_log = []
read_call_log = []
if identity:
RNS.log(f"Logging call event {event} for {RNS.prettyhexrep(identity.hash)}", RNS.LOG_DEBUG)
if self.logpath:
try:
with open(self.logpath, "rb") as logfile: read_call_log = msgpack.unpackb(logfile.read())
if not os.path.isfile(self.logpath):
try:
with open(self.logpath, "wb") as logfile: logfile.write(msgpack.packb([]))
except Exception as e: raise OSError("Could not create call log file")
call_log = []
read_call_log = []
try:
with open(self.logpath, "rb") as logfile: read_call_log = msgpack.unpackb(logfile.read())
except Exception as e:
RNS.log(f"Error while reading call log file: {e}", RNS.LOG_ERROR)
RNS.log(f"Call log file will be re-created", RNS.LOG_ERROR)
for entry in read_call_log:
age = time.time()-entry["time"]
if age < self.CALL_LOG_KEEP: call_log.append(entry)
entry = {"time": time.time(), "event": event, "identity": identity.hash}
call_log.append(entry)
with open(self.logpath, "wb") as logfile: logfile.write(msgpack.packb(call_log))
self.call_log = call_log
except Exception as e:
RNS.log(f"Error while reading call log file: {e}", RNS.LOG_ERROR)
RNS.log(f"Call log file will be re-created", RNS.LOG_ERROR)
for entry in read_call_log:
age = time.time()-entry["time"]
if age < self.CALL_LOG_KEEP: call_log.append(entry)
entry = {"time": time.time(), "event": event, "identity": identity.hash}
call_log.append(entry)
with open(self.logpath, "wb") as logfile: logfile.write(msgpack.packb(call_log))
self.call_log = call_log
except Exception as e:
RNS.log(f"An error occurred while updating call log: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
RNS.log(f"An error occurred while updating call log: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
def dial(self, identity_hash):
self.last_dialled_identity_hash = identity_hash

View file

@ -165,10 +165,12 @@ class Voice():
toast("Path request timed out")
def log_dial_action(self, sender=None):
if sender:
self.screen.ids.identity_hash.text = RNS.hexrep(sender.identity, delimit=False)
self.dial_target = sender.identity
self.dial_action()
if sender and self.app.sideband.voice_running and self.app.sideband.telephone != None:
telephone = self.app.sideband.telephone
if not telephone.is_ringing and not telephone.is_in_call and not telephone.call_is_connecting:
self.screen.ids.identity_hash.text = RNS.hexrep(sender.identity, delimit=False)
self.dial_target = sender.identity
self.dial_action()
def reject_action(self, sender=None):
if self.app.sideband.voice_running: