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