Initial commit
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user