mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
support additions
This commit is contained in:
parent
ec7de4b52f
commit
eec2f03ccb
@ -8,13 +8,14 @@ export default class PostsController extends Controller {
|
||||
|
||||
methods = {
|
||||
createPost: async (payload) => {
|
||||
const { user_id, message } = payload
|
||||
const { user_id, message, additions } = payload
|
||||
|
||||
const userData = await User.findById(user_id)
|
||||
|
||||
const post = new Post({
|
||||
user_id: typeof user_id === "object" ? user_id.toString() : user_id,
|
||||
message: String(message).toString(),
|
||||
additions: additions ?? [],
|
||||
created_at: new Date().getTime(),
|
||||
})
|
||||
|
||||
@ -178,11 +179,12 @@ export default class PostsController extends Controller {
|
||||
put = {
|
||||
"/post": Schematized({
|
||||
required: ["message"],
|
||||
select: ["message"],
|
||||
select: ["message", "additions"],
|
||||
}, async (req, res) => {
|
||||
const post = await this.methods.createPost({
|
||||
user_id: req.user.id,
|
||||
message: req.selection.message,
|
||||
additions: req.selection.additions,
|
||||
})
|
||||
|
||||
return res.json(post)
|
||||
|
Loading…
x
Reference in New Issue
Block a user