confirm each tag in auth event

This commit is contained in:
les
2021-03-19 00:35:54 +01:00
parent 6f35e2e1e2
commit dd98d2adc6

View File

@@ -307,7 +307,7 @@ const eventController = {
if (body.tags) { if (body.tags) {
await Tag.bulkCreate(body.tags.map(t => ({ tag: t, confirmed: !!req.user })), { ignoreDuplicates: true }) await Tag.bulkCreate(body.tags.map(t => ({ tag: t, confirmed: !!req.user })), { ignoreDuplicates: true })
const tags = await Tag.findAll({ where: { tag: { [Op.in]: body.tags } } }) const tags = await Tag.findAll({ where: { tag: { [Op.in]: body.tags } } })
await Promise.all(tags.map(t => t.update({ weigth: Number(t.weigth) + 1 }))) await Promise.all(tags.map(t => t.update({ weigth: Number(t.weigth) + 1, confirmed: true })))
await event.addTags(tags) await event.addTags(tags)
event.tags = tags event.tags = tags
} }