Initial commit

This commit is contained in:
payacom
2026-07-08 21:01:30 +03:30
parent 59c7c8e11c
commit 0b01b262fa
38 changed files with 1415 additions and 288 deletions

View File

@@ -3,6 +3,7 @@ const PostModel = require('../../../models/PostModel');
const jwt = require('jsonwebtoken');
const UserModel = require('../../../models/UserModel');
const LikeModel = require('../../../models/LikeModel');
const { createLikeNotification } = require('../../../utils/likeNotification');
const toggleLike = async (req, res, next) => {
try {
@@ -48,6 +49,13 @@ const toggleLike = async (req, res, next) => {
await post.save();
await LikeModel.create({ postId, userId });
await createLikeNotification({
ownerId: post.user_id,
likerId: userId,
entityId: post._id,
type: 'post_like'
});
return res.status(200).json({
message: 'پست با موفقیت لایک شد',
is_liked: true,

View File

@@ -5,6 +5,7 @@ const { check, validationResult } = require('express-validator');
const jwt = require('jsonwebtoken');
const path = require('path');
const { default: mongoose } = require('mongoose');
const { viewerIsBlockedBy } = require('../../../utils/blockVisibility');
const createPostValidationRules = () => {
console.log(4);
@@ -139,6 +140,15 @@ const getUserPostsWeb = async (req, res, next) => {
return res.status(404).json({ message: 'کاربر مورد نظر یافت نشد' })
}
if (userReqId && viewerIsBlockedBy(user, userReqId)) {
return res.status(200).json({
posts: [],
postsCount: 0,
totalPages: 0,
totalItems: 0,
})
}
const data = {}
const options = {
page: req.query.page || 1,