Initial commit

This commit is contained in:
payacom
2026-07-07 17:50:26 +03:30
parent 525565d685
commit 64eb8c288f
25 changed files with 801 additions and 231 deletions

30
utils/blockVisibility.js Normal file
View File

@@ -0,0 +1,30 @@
/** Viewer (blocked person) cannot see profile/posts of user who blocked them */
function viewerIsBlockedBy(user, viewerId) {
if (!user || !viewerId) return false
return user.blocked_users.some((id) => String(id) === String(viewerId))
}
function blockedProfilePayload(user) {
return {
_id: user._id,
user_name: user.user_name,
blocked_you: true,
is_self: false,
user_type: user.user_type,
postsCount: 0,
allProjectsCount: 0,
successfulProjectsCount: 0,
}
}
/** User IDs who have blocked the viewer */
async function getBlockerUserIds(UserModel, viewerId) {
if (!viewerId) return []
return UserModel.find({ blocked_users: viewerId }).distinct('_id')
}
module.exports = {
viewerIsBlockedBy,
blockedProfilePayload,
getBlockerUserIds,
}