From 256c47c33c5ed5d4c4d5229994fa0a48e08e35b6 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 28 Oct 2021 02:19:57 +0000 Subject: [PATCH] Ugg, need to get this talking SSB properly. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3677 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/ssb.js | 23 +++++++++++++---------- src/ssb.c | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/ssb.js b/core/ssb.js index 6147d30f..942d98bc 100644 --- a/core/ssb.js +++ b/core/ssb.js @@ -65,7 +65,7 @@ test_following(); ssb.registerConnectionsChanged(function(change, connection) { if (change == 'add') { connection.send_json({'name': ['createHistoryStream'], 'type': 'source', 'args': [{'id': connection.id, 'seq': 0}]}, function(message) { - ssb.storeMessage(message.message); + ssb.storeMessage(message.message.value); }); connection.send_json({'name': ['blobs', 'createWants'], 'type': 'source', 'args': []}, function(message) { Object.keys(message.message).forEach(function(id) { @@ -128,19 +128,22 @@ ssb.registerRpc(['createHistoryStream'], function(request) { var id = request.args[0].id; var seq = request.args[0].seq; ssb.sqlStream( - 'SELECT previous, sequence, timestamp, hash, content, signature FROM messages WHERE author = ?1 AND sequence >= ?2 ORDER BY sequence', + 'SELECT previous, id, sequence, timestamp, hash, content, signature FROM messages WHERE author = ?1 AND sequence >= ?2 ORDER BY sequence', [id, seq ?? 0], function(row) { var message = { - 'previous': row.previous, - 'author': id, - 'sequence': row.sequence, - 'timestamp': row.timestamp, - 'hash': row.hash, - 'content': JSON.parse(row.content), - 'signature': row.signature, + key: row.id + '.' + row.hash, + value: { + previous: row.previous, + author: id, + sequence: row.sequence, + timestamp: row.timestamp, + hash: row.hash, + content: JSON.parse(row.content), + signature: row.signature, + }, + timestamp: row.timestamp, }; - debug_print('sending1', JSON.stringify(message)); request.send_json(message); }); }); diff --git a/src/ssb.c b/src/ssb.c index 17e57c1a..0755ecf0 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -494,7 +494,7 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou } else { - printf("base64 decode author fail\n"); + printf("base64 decode author[%.*s] fail (%d)\n", (int)(type - author_id), author_id, r); } JS_FreeCString(context, author);