From e0a048abe62b74bdfecb08d1effbb3fd143e09ff Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 1 Jan 2025 15:28:19 -0500 Subject: [PATCH] follow: This app had never been updated since jsonb, whoops. #94 --- apps/follow.json | 3 ++- apps/follow/app.js | 46 +--------------------------------------------- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/apps/follow.json b/apps/follow.json index 3cf770d7..95aaddc1 100644 --- a/apps/follow.json +++ b/apps/follow.json @@ -1,4 +1,5 @@ { "type": "tildefriends-app", - "emoji": "➡️" + "emoji": "➡️", + "previous": "&YDDSzbRD8NFAykYlZnk4r4hAK5qXjT5LmKE6rhS1s+A=.sha256" } diff --git a/apps/follow/app.js b/apps/follow/app.js index 098f8f22..b8e8ed82 100644 --- a/apps/follow/app.js +++ b/apps/follow/app.js @@ -14,7 +14,7 @@ async function contacts_internal(id, last_row_id, following, max_row_id) { result.blocking = result.blocking || {}; let contacts = await query( ` - SELECT content FROM messages + SELECT json(content) AS content FROM messages WHERE author = ? AND rowid > ? AND rowid <= ? AND @@ -189,50 +189,6 @@ async function fetch_about(db, ids, users) { return Object.assign({}, users); } -async function getAbout(db, id) { - if (g_about_cache[id]) { - return g_about_cache[id]; - } - let o = await db.get(id + ':about'); - const k_version = 4; - let f = o ? JSON.parse(o) : o; - if (!f || f.version != k_version) { - f = {about: {}, sequence: 0, version: k_version}; - } - await ssb.sqlAsync( - 'SELECT ' + - ' sequence, ' + - ' content ' + - 'FROM messages ' + - 'WHERE ' + - ' author = ?1 AND ' + - ' sequence > ?2 AND ' + - " json_extract(content, '$.type') = 'about' AND " + - " json_extract(content, '$.about') = ?1 " + - 'UNION SELECT MAX(sequence) as sequence, NULL FROM messages WHERE author = ?1 ' + - 'ORDER BY sequence', - [id, f.sequence], - function (row) { - f.sequence = row.sequence; - if (row.content) { - let about = {}; - try { - about = JSON.parse(row.content); - } catch {} - delete about.about; - delete about.type; - f.about = Object.assign(f.about, about); - } - } - ); - let j = JSON.stringify(f); - if (o != j) { - await db.set(id + ':about', j); - } - g_about_cache[id] = f.about; - return f.about; -} - async function getSize(db, id) { let size = 0; await ssb.sqlAsync(