server: fix post creation

This commit is contained in:
Max Leiter 2022-03-28 12:28:07 -07:00
parent e0b0102603
commit 333e3647e0
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA

View file

@ -80,20 +80,20 @@ posts.post(
.digest("hex")
.toString(),
html: html || '',
userId: req.body.userId,
postId: newPost.id
})
await newFile.$set("user", req.body.userId)
await newFile.$set("post", newPost.id)
await newFile.save()
return newFile
})
)
await Promise.all(
newFiles.map((file) => {
newPost.$add("files", file.id)
newFiles.map(async (file) => {
await newPost.$add("files", file.id)
await newPost.save()
})
)
await newPost.save()
res.json(newPost)
} catch (e) {