fix: resolve MongoDB connection and port configuration issues
- Added dotenv configuration for environment variables - Fixed MongoDB connection string loading - Configured server port to 3005 - Updated cron jobs for expired messages
This commit is contained in:
@@ -1,57 +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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user