From 85c5b4c4d6ad765118fb6d1c987daa4876af1477 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 13 Jan 2021 02:39:20 +0000 Subject: [PATCH] Remove pubs from the ssb client app. Not used. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3639 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/cory/index.json | 2 +- apps/cory/index/app.js | 50 ------------------------------------------ 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/apps/cory/index.json b/apps/cory/index.json index 16df43f7..cc7e8a3d 100644 --- a/apps/cory/index.json +++ b/apps/cory/index.json @@ -1 +1 @@ -{"type":"tildefriends-app","files":{"app.js":"&QC3jbGKlu7N1D7w6L64MUuT0EWf0MSew1gEg4LbaFcM=.sha256","index.html":"&eqLI+5Abbs4OEjIO7neOQFjhm/iknp6gi96RD2VTAR0=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256"}} \ No newline at end of file +{"type":"tildefriends-app","files":{"app.js":"&qvp1qQcymJp9pWxnZXA9/VXFt6FRGj9JCAxNCt/afsU=.sha256","index.html":"&eqLI+5Abbs4OEjIO7neOQFjhm/iknp6gi96RD2VTAR0=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256"}} \ No newline at end of file diff --git a/apps/cory/index/app.js b/apps/cory/index/app.js index 51ebe078..0aeb6c89 100644 --- a/apps/cory/index/app.js +++ b/apps/cory/index/app.js @@ -99,55 +99,6 @@ async function sendUser(db, id) { ]); } -async function pubsByUser(db, id) { - var o = await db.get(id + ":pubs"); - const k_version = 3; - var f = o ? JSON.parse(o) : o; - if (!f || f.version != k_version) { - f = {pubs: [], sequence: 0, version: k_version}; - } - f.pubs = Object.fromEntries(f.pubs.map(x => [JSON.stringify(x), x])); - await ssb.sqlStream( - "SELECT "+ - " sequence, "+ - " json_extract(content, '$.address.host') AS host, "+ - " json_extract(content, '$.address.port') AS port, "+ - " json_extract(content, '$.address.key') AS key "+ - "FROM messages "+ - "WHERE "+ - " sequence > ?1 AND "+ - " author = ?2 AND "+ - " json_extract(content, '$.type') = 'pub' "+ - "UNION SELECT MAX(sequence) as sequence, NULL, NULL, NULL FROM messages WHERE author = ?2 "+ - "ORDER BY sequence", - [f.sequence, id], - function(row) { - f.sequence = row.sequence; - if (row.host) { - row = {host: row.host, port: row.port, key: row.key}; - f.pubs[JSON.stringify(row)] = row; - } - }); - f.pubs = Object.values(f.pubs); - var j = JSON.stringify(f); - if (o != j) { - await db.set(id + ":pubs", j); - } - return f.pubs; -} - -async function visiblePubs(db, id) { - var ids = [id].concat(await following(db, id)); - var pubs = {}; - for (var follow of ids) { - var followPubs = await pubsByUser(db, follow); - for (var pub of followPubs) { - pubs[JSON.stringify(pub)] = pub; - } - } - return Object.values(pubs); -} - async function getAbout(db, id) { var o = await db.get(id + ":about"); const k_version = 4; @@ -309,7 +260,6 @@ async function refresh() { var db = await database("ssb"); await Promise.all([ app.postMessage({whoami: whoami}), - app.postMessage({pubs: await visiblePubs(db, whoami)}), app.postMessage({broadcasts: await ssb.getBroadcasts()}), app.postMessage({connections: await ssb.connections()}), app.postMessage({apps: await core.apps()}),