Include active quizs.id in the /feed/meet API

This commit is contained in:
Niko 2022-02-23 14:49:03 +01:00
parent 791bb1eaf0
commit 8dc1923219
1 changed files with 14 additions and 3 deletions

View File

@ -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,
})
}