async function get_apps() { let results = {}; await ssb.sqlAsync(` SELECT messages.* FROM messages_fts('"application/tildefriends"') JOIN messages ON messages.rowid = messages_fts.rowid ORDER BY timestamp `, [], function(row) { let content = JSON.parse(row.content); for (let mention of content.mentions) { if (mention?.type === 'application/tildefriends') { results[JSON.stringify([row.author, mention.name])] = { message: row, blob: mention.link, name: mention.name, }; } } }); return Object.values(results).sort((x, y) => y.message.timestamp - x.message.timestamp); } function render_app(app) { return `
@ % ${app.name}
`; } async function main() { let apps = await get_apps(); app.setDocument(`

${apps.length} apps

${apps.map(render_app).join('\n')} `); } main();