From 8dc192321935a6553e87bf77e7436260f409fb3e Mon Sep 17 00:00:00 2001 From: Niko Date: Wed, 23 Feb 2022 14:49:03 +0100 Subject: [PATCH] Include active quizs.id in the /feed/meet API --- api/src/api/feed.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/src/api/feed.js b/api/src/api/feed.js index b1a354f..4f86bd1 100644 --- a/api/src/api/feed.js +++ b/api/src/api/feed.js @@ -31,6 +31,12 @@ module.exports = { filter['attributedTo'] = { $nin : urlblocks } } + const mquizs = await api.me.getQuizs(apID(res.locals.user.username), + { parseToAccount: false }, { id: 1, from: 1 }) + var quizActors = {} + for (var i in mquizs) + quizActors[mquizs[i].from] = mquizs[i] + const notes = await db.table.objects() .find(filter) .sort({ _id: -1 }) @@ -48,13 +54,18 @@ module.exports = { }) } } + + var quizId = null + const accountActor = utils.firstIfArray(note.attributedTo) + if (Object.keys(quizActors).includes(accountActor)) + quizId = quizActors[accountActor].id + results.push({ _id: note._id, text: utils.firstIfArray(note.content), date: utils.firstIfArray(note.published), - account: await api.accounts.getAccount( - utils.firstIfArray(note.attributedTo) - ), + account: await api.accounts.getAccount(accountActor), + quiz_id: quizId, tags, }) }