Compare commits

...

2 Commits

Author SHA1 Message Date
852c25296a ssb: Better errors for failing to decrypt private messages.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 22m32s
2024-12-27 13:38:09 -05:00
aea631138e ssb: Fix private messages starting with unread status when there are none. 2024-12-27 13:25:40 -05:00
3 changed files with 40 additions and 32 deletions

View File

@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🦀", "emoji": "🦀",
"previous": "&XjeQP84BXBKSEViNV3c10QisKyGv14Kngfwx3IqorX8=.sha256" "previous": "&SM9hI4To1+vk52CT8S2VvnhAynikIX27IFxqZIfNGAY=.sha256"
} }

View File

@ -112,6 +112,7 @@ class TfTabNewsElement extends LitElement {
unread_status(channel) { unread_status(channel) {
if ( if (
this.channels_latest[channel] && this.channels_latest[channel] &&
this.channels_latest[channel] > 0 &&
(this.channels_unread[channel] === undefined || (this.channels_unread[channel] === undefined ||
this.channels_unread[channel] <= this.channels_latest[channel]) this.channels_unread[channel] <= this.channels_latest[channel])
) { ) {

View File

@ -2238,6 +2238,8 @@ static void _tf_ssb_private_message_decrypt_work(tf_ssb_t* ssb, void* user_data)
tf_ssb_release_db_reader(ssb, db); tf_ssb_release_db_reader(ssb, db);
if (found) if (found)
{
if (work->message_size >= strlen(".box") && memcmp(work->message + work->message_size - strlen(".box"), ".box", strlen(".box")) == 0)
{ {
uint8_t* decoded = tf_malloc(work->message_size); uint8_t* decoded = tf_malloc(work->message_size);
int decoded_length = tf_base64_decode(work->message, work->message_size - strlen(".box"), decoded, work->message_size); int decoded_length = tf_base64_decode(work->message, work->message_size - strlen(".box"), decoded, work->message_size);
@ -2283,11 +2285,16 @@ static void _tf_ssb_private_message_decrypt_work(tf_ssb_t* ssb, void* user_data)
} }
else else
{ {
work->error = "Encrypted message was not long enough to contains its one-time public key."; work->error = "Encrypted message was not long enough to contain its one-time public key.";
} }
tf_free(decoded); tf_free(decoded);
} }
else else
{
work->error = "Message does not end in \".box\".";
}
}
else
{ {
work->error = "Private key not found for user."; work->error = "Private key not found for user.";
} }