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
This commit is contained in:
Cory McWilliams 2021-10-28 02:19:57 +00:00
parent 62ad08985c
commit 256c47c33c
2 changed files with 14 additions and 11 deletions

View File

@ -65,7 +65,7 @@ test_following();
ssb.registerConnectionsChanged(function(change, connection) { ssb.registerConnectionsChanged(function(change, connection) {
if (change == 'add') { if (change == 'add') {
connection.send_json({'name': ['createHistoryStream'], 'type': 'source', 'args': [{'id': connection.id, 'seq': 0}]}, function(message) { 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) { connection.send_json({'name': ['blobs', 'createWants'], 'type': 'source', 'args': []}, function(message) {
Object.keys(message.message).forEach(function(id) { Object.keys(message.message).forEach(function(id) {
@ -128,19 +128,22 @@ ssb.registerRpc(['createHistoryStream'], function(request) {
var id = request.args[0].id; var id = request.args[0].id;
var seq = request.args[0].seq; var seq = request.args[0].seq;
ssb.sqlStream( 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], [id, seq ?? 0],
function(row) { function(row) {
var message = { var message = {
'previous': row.previous, key: row.id + '.' + row.hash,
'author': id, value: {
'sequence': row.sequence, previous: row.previous,
'timestamp': row.timestamp, author: id,
'hash': row.hash, sequence: row.sequence,
'content': JSON.parse(row.content), timestamp: row.timestamp,
'signature': row.signature, hash: row.hash,
content: JSON.parse(row.content),
signature: row.signature,
},
timestamp: row.timestamp,
}; };
debug_print('sending1', JSON.stringify(message));
request.send_json(message); request.send_json(message);
}); });
}); });

View File

@ -494,7 +494,7 @@ bool tf_ssb_verify_and_strip_signature(JSContext* context, JSValue val, char* ou
} }
else 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); JS_FreeCString(context, author);