This lets me post a 'tildefriends-app' message.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3634 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-01-09 22:19:52 +00:00
parent a2851f8ade
commit d8657866f5
3 changed files with 36 additions and 6 deletions

View File

@@ -168,7 +168,7 @@ async function getAbout(db, id) {
"UNION SELECT MAX(sequence) as sequence, NULL FROM messages WHERE author = ?2 "+
"ORDER BY sequence",
[f.sequence, id],
async function(row) {
function(row) {
f.sequence = row.sequence;
if (row.content) {
var about = {};
@@ -199,7 +199,7 @@ function fnv32a(value)
}
async function getRecentPostIds(db, id, ids, limit) {
const k_version = 6;
const k_version = 7;
var o = await db.get(id + ':recent_posts');
var recent = [];
var f = o ? JSON.parse(o) : o;
@@ -215,7 +215,7 @@ async function getRecentPostIds(db, id, ids, limit) {
"WHERE "+
" rowid > ? AND "+
" author IN (" + ids.map(x => '?').join(", ") + ") AND "+
" json_extract(content, '$.type') = 'post' "+
" json_extract(content, '$.type') IN ('post', 'tildefriends-app') "+
"UNION SELECT MAX(rowid) as rowid, NULL FROM messages "+
"ORDER BY rowid DESC LIMIT ?",
[].concat([f.rowid], ids, [limit + 1]),
@@ -280,7 +280,7 @@ async function getPosts(db, ids) {
await ssb.sqlStream(
"SELECT rowid, * FROM messages WHERE id IN (" + ids.map(x => "?").join(", ") + ")",
ids,
async function(row) {
function(row) {
try {
posts.push(row);
} catch {
@@ -312,6 +312,7 @@ async function refresh() {
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()}),
followingDeep(db, [whoami], 2).then(function(f) {
getRecentPostIds(db, whoami, [].concat([whoami], f), k_posts_max).then(async function(ids) {
return getPosts(db, ids);
@@ -357,6 +358,12 @@ core.register('message', async function(m) {
await ssb.post(m.message.post);
} else if (m.message.appendMessage) {
await ssb.appendMessage(m.message.appendMessage);
} else if (m.message.share_app) {
var app = await ssb.blobGet(m.message.share_app.app);
app = JSON.parse(utf8Decode(app));
app.type = 'tildefriends-app';
app.name = m.message.share_app.name;
await ssb.appendMessage(app);
} else if (m.message.user) {
await sendUser(await database("ssb"), m.message.user);
} else if (m.message.refresh) {