First glimpse of multiple SSB identities per Tilde Friends user.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3941 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-07-31 19:01:08 +00:00
parent 0bd1463a6b
commit 24530e1158
9 changed files with 108 additions and 80 deletions

View File

@ -249,6 +249,13 @@ async function getProcessBlob(blobId, key, options) {
return ssb.getIdentities(process.credentials.session.name);
}
};
imports.ssb.appendMessageWithIdentity = function(id, message) {
if (process.credentials &&
process.credentials.session &&
process.credentials.session.name) {
return ssb.appendMessageWithIdentity(process.credentials.session.name, id, message);
}
};
if (process.credentials &&
process.credentials.session &&
process.credentials.session.name) {

View File

@ -77,10 +77,10 @@ ssb.addEventListener('connections', function(change, connection) {
var sequence = get_latest_sequence_for_author(connection.id);
if (k_use_create_history_stream) {
connection.send_json({'name': ['createHistoryStream'], 'type': 'source', 'args': [{'id': connection.id, 'seq': sequence, 'live': true, 'keys': false}]}, storeMessage);
var me = ssb.whoami();
followingDeep(g_database, [me], 2).then(function(ids) {
var identities = ssb.getAllIdentities();
followingDeep(g_database, identities, 2).then(function(ids) {
for (let id of ids) {
if (id == me) {
if (identities.indexOf(id) != -1) {
continue;
}
var sequence = get_latest_sequence_for_author(id);
@ -201,10 +201,10 @@ ssb.addRpc(['tunnel', 'isRoom'], function(request) {
});
function ebtReplicateSendClock(request, have) {
var me = ssb.whoami();
var identities = ssb.getAllIdentities();
var message = {};
var last_sent = request.connection.sent_clock || {};
var ids = followingDeep(g_database, [me], 2).concat([request.connection.id]);
var ids = followingDeep(g_database, identities, 2).concat([request.connection.id]);
if (!Object.keys(last_sent).length) {
for (let id of ids) {
message[id] = get_latest_sequence_for_author(id);
@ -261,11 +261,10 @@ function formatMessage(row) {
}
function ebtReplicateRegisterMessageCallback(request) {
var me = ssb.whoami();
ssb.addEventListener('message', function(message_id) {
ssb.sqlStream(
'SELECT previous, author, id, sequence, timestamp, hash, content, signature FROM messages WHERE id = ?1 AND author = ?2',
[message_id, me],
'SELECT previous, author, id, sequence, timestamp, hash, content, signature FROM messages WHERE id = ?1',
[message_id],
function (row) {
request.send_json(formatMessage(row));
});
@ -273,7 +272,6 @@ function ebtReplicateRegisterMessageCallback(request) {
}
function ebtReplicateCommon(request) {
var me = ssb.whoami();
if (request.message.author) {
storeMessage(request);
} else {