1
0
mirror of https://github.com/ragestudio/comty.git synced 2025-06-18 23:14:15 +00:00

25 lines
428 B
JavaScript

import { Post } from "@db_models"
import stage from "./stage"
export default async (payload = {}) => {
const { post_id, for_user_id, trim = 0, limit = 50 } = payload
if (!post_id) {
throw new OperationError(400, "Post ID is required")
}
let posts = await Post.find({
reply_to: post_id,
})
.limit(limit)
.skip(trim)
.sort({ created_at: -1 })
posts = await stage({
posts,
for_user_id,
})
return posts
}