Continuing to try to get this thing talking to other clients.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3679 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-10-31 19:39:16 +00:00
parent 0a01332d1f
commit 08cd0ec878
3 changed files with 38 additions and 11 deletions

View File

@ -62,23 +62,24 @@ async function test_following() {
test_following();
async function get_latest_sequence_for_author(author) {
function get_latest_sequence_for_author(author) {
var sequence = 0;
await ssb.sqlStream(
ssb.sqlStream(
'SELECT MAX(sequence) AS sequence FROM messages WHERE author = ?1',
[author],
function(row) {
sequence = row.sequence + 1;
if (row.sequence) {
sequence = row.sequence + 1;
}
});
return sequence;
}
ssb.registerConnectionsChanged(function(change, connection) {
if (change == 'add') {
get_latest_sequence_for_author(connection.id).then(function(sequence) {
connection.send_json({'name': ['createHistoryStream'], 'type': 'source', 'args': [{'id': connection.id, 'seq': sequence}]}, function(message) {
ssb.storeMessage(message.message.value);
});
var sequence = get_latest_sequence_for_author(connection.id);
connection.send_json({'name': ['createHistoryStream'], 'type': 'source', 'args': [{'id': connection.id, 'seq': sequence}]}, function(message) {
ssb.storeMessage(message.message.value);
});
connection.send_json({'name': ['blobs', 'createWants'], 'type': 'source', 'args': []}, function(message) {
Object.keys(message.message).forEach(function(id) {
@ -133,8 +134,10 @@ ssb.registerRpc(['blobs', 'has'], function(request) {
});
ssb.registerRpc(['blobs', 'get'], function(request) {
var blob = ssb.blobGet(request.args[0].id);
request.send_binary(blob);
for (let id of request.args) {
var blob = ssb.blobGet(id);
request.send_binary(blob);
}
});
ssb.registerRpc(['createHistoryStream'], function(request) {