full
This commit is contained in:
29
utils/academyNotification.js
Normal file
29
utils/academyNotification.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const NotificationModel = require("../models/NotificationModel");
|
||||
|
||||
const PURCHASE_TITLE = "پکیج شما خریداری شد";
|
||||
const PURCHASE_DESCRIPTION = "یک کاربر پکیج آموزشی شما را خریداری کرد";
|
||||
|
||||
const createCoursePurchaseNotification = async ({
|
||||
ownerId,
|
||||
buyerId,
|
||||
courseId,
|
||||
}) => {
|
||||
try {
|
||||
if (!ownerId || !buyerId || !courseId) return;
|
||||
if (String(ownerId) === String(buyerId)) return;
|
||||
|
||||
await NotificationModel.create({
|
||||
user_id: ownerId,
|
||||
project_post_id: courseId,
|
||||
type: "academy_purchase",
|
||||
title: PURCHASE_TITLE,
|
||||
description: PURCHASE_DESCRIPTION,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error creating course purchase notification:", error);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
createCoursePurchaseNotification,
|
||||
};
|
||||
Reference in New Issue
Block a user