30 lines
803 B
JavaScript
30 lines
803 B
JavaScript
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,
|
|
};
|