mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 05:20:36 +01:00
Display outgoing stamps in message details
This commit is contained in:
parent
12b7250a37
commit
edb07c7cea
@ -2388,13 +2388,39 @@ class SidebandCore():
|
||||
dbc.execute(query, {"outbound_state": LXMF.LXMessage.OUTBOUND, "sending_state": LXMF.LXMessage.SENDING})
|
||||
db.commit()
|
||||
|
||||
def _db_message_set_state(self, lxm_hash, state, is_retry=False):
|
||||
def _db_message_set_state(self, lxm_hash, state, is_retry=False, ratchet_id=None, originator_stamp=None):
|
||||
msg_extras = None
|
||||
if ratchet_id != None:
|
||||
try:
|
||||
msg = self._db_message(lxm_hash)
|
||||
if msg != None:
|
||||
msg_extras = msg["extras"]
|
||||
|
||||
if ratchet_id:
|
||||
msg_extras["ratchet_id"] = ratchet_id
|
||||
|
||||
if originator_stamp:
|
||||
msg_extras["stamp_checked"] = False
|
||||
msg_extras["stamp_raw"] = originator_stamp[0]
|
||||
msg_extras["stamp_valid"] = originator_stamp[1]
|
||||
msg_extras["stamp_value"] = originator_stamp[2]
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("An error occurred while getting message extras: "+str(e))
|
||||
|
||||
with self.db_lock:
|
||||
db = self.__db_connect()
|
||||
dbc = db.cursor()
|
||||
|
||||
query = "UPDATE lxm set state = ? where lxm_hash = ?"
|
||||
data = (state, lxm_hash)
|
||||
if msg_extras != None:
|
||||
extras = msgpack.packb(msg_extras)
|
||||
query = "UPDATE lxm set state = ?, extra = ? where lxm_hash = ?"
|
||||
data = (state, extras, lxm_hash)
|
||||
|
||||
else:
|
||||
query = "UPDATE lxm set state = ? where lxm_hash = ?"
|
||||
data = (state, lxm_hash)
|
||||
|
||||
dbc.execute(query, data)
|
||||
|
||||
try:
|
||||
@ -3934,7 +3960,10 @@ class SidebandCore():
|
||||
|
||||
if self._db_message(message.hash):
|
||||
RNS.log("Message exists, setting state to: "+str(message.state), RNS.LOG_DEBUG)
|
||||
self._db_message_set_state(message.hash, message.state)
|
||||
stamp = None
|
||||
if originator and message.stamp != None:
|
||||
stamp = [message.stamp, message.stamp_valid, message.stamp_value]
|
||||
self._db_message_set_state(message.hash, message.state, ratchet_id=message.ratchet_id, originator_stamp=stamp)
|
||||
else:
|
||||
RNS.log("Message does not exist, saving", RNS.LOG_DEBUG)
|
||||
self._db_save_lxm(message, context_dest, originator, own_command=own_command)
|
||||
|
@ -104,6 +104,7 @@ class Messages():
|
||||
def message_details_dialog(self, lxm_hash):
|
||||
RNS.log(f"Opening dialog for {RNS.prettyhexrep(lxm_hash)}", RNS.LOG_DEBUG)
|
||||
ss = int(dp(16))
|
||||
ms = int(dp(14))
|
||||
|
||||
msg = self.app.sideband.message(lxm_hash)
|
||||
if msg:
|
||||
@ -119,21 +120,23 @@ class Messages():
|
||||
else:
|
||||
d_text += f"[size={ss}][b]Signature[/b] is invalid[/size]\n"
|
||||
|
||||
ratchet_method = ""
|
||||
if "method" in msg:
|
||||
if msg["method"] == LXMF.LXMessage.UNKNOWN:
|
||||
d_text += f"[size={ss}][b]Delivered[/b] via unknown method[/size]\n"
|
||||
if msg["method"] == LXMF.LXMessage.OPPORTUNISTIC:
|
||||
d_text += f"[size={ss}][b]Delivered[/b] opportunistically[/size]\n"
|
||||
if msg["method"] == LXMF.LXMessage.DIRECT:
|
||||
ratchet_method = "link "
|
||||
d_text += f"[size={ss}][b]Delivered[/b] over direct link[/size]\n"
|
||||
if msg["method"] == LXMF.LXMessage.PROPAGATED:
|
||||
d_text += f"[size={ss}][b]Delivered[/b] to propagation network[/size]\n"
|
||||
|
||||
if msg["extras"] != None and "ratchet_id" in msg["extras"]:
|
||||
r_str = RNS.prettyhexrep(msg["extras"]["ratchet_id"])
|
||||
d_text += f"[size={ss}][b]Encrypted[/b] with ratchet {r_str}[/size]\n"
|
||||
d_text += f"[size={ss}][b]Encrypted[/b] with {ratchet_method}ratchet {r_str}[/size]\n"
|
||||
|
||||
if msg["extras"] != None and "stamp_checked" in msg["extras"] and msg["extras"]["stamp_checked"] == True:
|
||||
if msg["extras"] != None and "stamp_checked" in msg["extras"]:
|
||||
valid_str = " is not valid"
|
||||
if msg["extras"]["stamp_valid"] == True:
|
||||
valid_str = " is valid"
|
||||
@ -146,11 +149,24 @@ class Messages():
|
||||
else:
|
||||
sv_str = f"with value {sv}"
|
||||
|
||||
if msg["extras"]["stamp_checked"] == True:
|
||||
d_text += f"[size={ss}][b]Stamp[/b] {sv_str}{valid_str}[/size]\n"
|
||||
|
||||
else:
|
||||
sv = msg["extras"]["stamp_value"]
|
||||
if sv == None:
|
||||
pass
|
||||
elif sv > 255:
|
||||
d_text += f"[size={ss}][b]Stamp[/b] generated from ticket[/size]\n"
|
||||
else:
|
||||
d_text += f"[size={ss}][b]Value[/b] of stamp is {sv}[/size]\n"
|
||||
|
||||
# Stamp details
|
||||
if "stamp_raw" in msg["extras"] and type(msg["extras"]["stamp_raw"]) == bytes:
|
||||
sstr = RNS.hexrep(msg["extras"]["stamp_raw"])
|
||||
d_text += f"[size={ss}][b]Raw stamp[/b] {sstr}[/size]\n"
|
||||
|
||||
d_text += f"[size={ss}][b]Stamp[/b] {sv_str}{valid_str}[/size]\n"
|
||||
sstr1 = RNS.hexrep(msg["extras"]["stamp_raw"][:16])
|
||||
sstr2 = RNS.hexrep(msg["extras"]["stamp_raw"][16:])
|
||||
d_text += f"[size={ss}]\n[b]Raw stamp[/b]\n[/size][size={ms}][font=RobotoMono-Regular]{sstr1}\n{sstr2}[/font][/size]\n"
|
||||
|
||||
self.details_dialog = MDDialog(
|
||||
title="Message Details",
|
||||
@ -484,8 +500,9 @@ class Messages():
|
||||
heading_str = titlestr
|
||||
if phy_stats_str != "" and self.app.sideband.config["advanced_stats"]:
|
||||
heading_str += phy_stats_str+"\n"
|
||||
if stamp_valid:
|
||||
txstr += f" [b]Stamp[/b] value is {stamp_value} "
|
||||
# TODO: Remove
|
||||
# if stamp_valid:
|
||||
# txstr += f" [b]Stamp[/b] value is {stamp_value} "
|
||||
|
||||
heading_str += "[b]Sent[/b] "+txstr
|
||||
heading_str += "\n[b]Received[/b] "+rxstr
|
||||
|
Loading…
Reference in New Issue
Block a user