Report some information when importing messages and discover an old verification bug.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4293 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
21
src/ssb.c
21
src/ssb.c
@ -963,7 +963,7 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (out_sequence_before_author)
|
||||
else
|
||||
{
|
||||
JSValue reordered = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, reordered, "previous", JS_GetPropertyStr(context, val, "previous"));
|
||||
@ -977,7 +977,10 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou
|
||||
JS_FreeValue(context, reordered);
|
||||
if (result)
|
||||
{
|
||||
*out_sequence_before_author = true;
|
||||
if (out_sequence_before_author)
|
||||
{
|
||||
*out_sequence_before_author = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -3373,25 +3376,33 @@ tf_ssb_blob_wants_t* tf_ssb_connection_get_blob_wants_state(tf_ssb_connection_t*
|
||||
return connection ? &connection->blob_wants : NULL;
|
||||
}
|
||||
|
||||
bool tf_ssb_verify_strip_and_store_message(tf_ssb_t* ssb, JSValue value)
|
||||
bool tf_ssb_verify_strip_and_store_message(tf_ssb_t* ssb, JSValue value, bool* out_is_new)
|
||||
{
|
||||
JSContext* context = tf_ssb_get_context(ssb);
|
||||
char signature[crypto_sign_BYTES + 128] = { 0 };
|
||||
char id[crypto_hash_sha256_BYTES * 2 + 1] = { 0 };
|
||||
bool sequence_before_author = false;
|
||||
if (out_is_new)
|
||||
{
|
||||
*out_is_new = false;
|
||||
}
|
||||
if (tf_ssb_verify_and_strip_signature(context, value, id, sizeof(id), signature, sizeof(signature), &sequence_before_author))
|
||||
{
|
||||
if (tf_ssb_db_store_message(ssb, context, id, value, signature, sequence_before_author))
|
||||
{
|
||||
tf_ssb_notify_message_added(ssb, id);
|
||||
return true;
|
||||
if (out_is_new)
|
||||
{
|
||||
*out_is_new = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_printf("failed to verify message\n");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tf_ssb_connection_get_sent_clock(tf_ssb_connection_t* connection)
|
||||
|
Reference in New Issue
Block a user