reportPost = async (req, res) => {
  try {
    const { postId, reportReason, communityId } = req.body.info;

    if (!postId || !reportReason) {
      return res.status(400).json({
        message: "Invalid data. postId and reportReason are required.",
      });
    }

    const reportedPost = await Report.findOne({
      post: {$eq: postId},
    });

    if (reportedPost) {
      if (reportedPost.reportedBy.includes(req.userId)) {
        return res.status(400).json({
          message: "You have already reported this post.",
        });
      }

      reportedPost.reportedBy.push(req.userId);
      await reportedPost.save();

      return res.status(200).json(reportedPost);
    }

    const report = {
      post: postId,
      community: communityId,
      reportedBy: [req.userId],
      reportReason,
      reportDate: new Date(),
    };

    await Report.create(report);

    res.status(200).json({ message: "Post reported successfully." });
  } catch (error) {
    res.status(500).json({
      message: "Error reporting post",
    });
  }
}
If a particular post has not been reported by anyone, create a new report. Otherwise, add the user to the list of users who have reported the post.
A post can be reported by multiple users but only once by each user.

@route POST /communities/:name/report