Skip to content

Commit

Permalink
Add timestamp and expiry to notification metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerman committed Sep 18, 2023
1 parent 901b617 commit a5da523
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions spns/hivemind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ WHERE account = $1
3 + 21 + hash.size() + // 1:# N:hash
3 + 36 + // 1:@ 33:account
3 + 8 + // 1:n i-32768e
3 + 15 + // 1:t i1695078498534e (timestamp)
3 + 15 + // 1:t i1695078498534e (expiry)
(svcdata ? 3 + 21 + svcdata->size() : 0) +
(want_data && maybe_data ? 3 + 21 + maybe_data->size() : 0);

Expand All @@ -604,6 +606,8 @@ WHERE account = $1
dict.append("@", account.sv());
dict.append("^", enc_key.sv());
dict.append("n", ns);
dict.append("t", timestamp_ms);
dict.append("z", expiry_ms);
if (want_data && maybe_data)
dict.append("~", *maybe_data);
} catch (const std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion spns/notifiers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def encrypt_payload(msg: bytes, enc_key: bytes):
def encrypt_notify_payload(data: dict, max_msg_size: int = 2500):
enc_key = data[b"^"]

metadata = {"@": data[b"@"].hex(), "#": data[b"#"].decode(), "n": data[b"n"]}
metadata = {"@": data[b"@"].hex(), "#": data[b"#"].decode(), "n": data[b"n"], "t": data[b"t"], "z": data[b"z"]}
body = data.get(b"~")

if body:
Expand Down

0 comments on commit a5da523

Please sign in to comment.