confirm tag/place only if auth

This commit is contained in:
les 2020-08-31 16:47:33 +02:00
parent f73168ae9e
commit f9f29154a2

View file

@ -277,7 +277,10 @@ const eventController = {
const [place] = await Place.findOrCreate({ const [place] = await Place.findOrCreate({
where: { name: body.place_name }, where: { name: body.place_name },
defaults: { address: body.place_address } defaults: {
address: body.place_address,
confirmed: !!req.user
}
}) })
await event.setPlace(place) await event.setPlace(place)
@ -285,7 +288,7 @@ const eventController = {
// create/assign tags // create/assign tags
if (body.tags) { if (body.tags) {
await Tag.bulkCreate(body.tags.map(t => ({ tag: t })), { 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 })))
await event.addTags(tags) await event.addTags(tags)