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

@@ -0,0 +1,57 @@
const NotificationModel = require('../models/NotificationModel')
const { resolveCourseOwnerId } = require('./likeNotification')
const COMMENT_TITLE = 'یک کامنت برای شما ثبت شد'
const COMMENT_DESCRIPTION = 'یک کامنت برای شما ثبت شد'
const RATING_TITLE = 'یک امتیاز برای شما ثبت شد'
const RATING_DESCRIPTION = 'یک امتیاز برای شما ثبت شد'
const createCommentNotification = async ({
ownerId,
commenterId,
entityId,
type = 'post_comment'
}) => {
try {
if (!ownerId || !commenterId || !entityId) return
if (String(ownerId) === String(commenterId)) return
await NotificationModel.create({
user_id: ownerId,
project_post_id: entityId,
type,
title: COMMENT_TITLE,
description: COMMENT_DESCRIPTION
})
} catch (error) {
console.error('Error creating comment notification:', error)
}
}
const createRatingNotification = async ({
ownerId,
raterId,
entityId,
type = 'billboard_rating'
}) => {
try {
if (!ownerId || !raterId || !entityId) return
if (String(ownerId) === String(raterId)) return
await NotificationModel.create({
user_id: ownerId,
project_post_id: entityId,
type,
title: RATING_TITLE,
description: RATING_DESCRIPTION
})
} catch (error) {
console.error('Error creating rating notification:', error)
}
}
module.exports = {
createCommentNotification,
createRatingNotification,
resolveCourseOwnerId
}