feat: nambahin link field di Notification
This commit is contained in:
@@ -5,13 +5,14 @@ const { data, error } = require('../../../helpers/utils/wrapper');
|
||||
const { NotFoundError, ForbiddenError, BadRequestError } = require('../../../helpers/error');
|
||||
|
||||
class NotificationService {
|
||||
async createNotificationForIntern(userId, title, message) {
|
||||
async createNotificationForIntern(userId, title, message, link = '') {
|
||||
try {
|
||||
const notification = await notificationRepository.create({
|
||||
id_user: parseInt(userId),
|
||||
id_admin: null,
|
||||
title,
|
||||
message,
|
||||
link,
|
||||
is_read: false
|
||||
});
|
||||
|
||||
@@ -26,13 +27,14 @@ class NotificationService {
|
||||
}
|
||||
}
|
||||
|
||||
async createNotificationForMentor(adminId, title, message) {
|
||||
async createNotificationForMentor(adminId, title, message, link = '') {
|
||||
try {
|
||||
const notification = await notificationRepository.create({
|
||||
id_user: null,
|
||||
id_admin: parseInt(adminId),
|
||||
title,
|
||||
message,
|
||||
link,
|
||||
is_read: false
|
||||
});
|
||||
|
||||
@@ -47,7 +49,7 @@ class NotificationService {
|
||||
}
|
||||
}
|
||||
|
||||
async createNotificationForProjectInterns(projectId, title, message) {
|
||||
async createNotificationForProjectInterns(projectId, title, message, link = '') {
|
||||
try {
|
||||
const project = await taskRepository.findProjectById(projectId);
|
||||
if (!project || !project.members) {
|
||||
@@ -56,7 +58,7 @@ class NotificationService {
|
||||
|
||||
const results = [];
|
||||
for (const member of project.members) {
|
||||
const res = await this.createNotificationForIntern(member.id_user, title, message);
|
||||
const res = await this.createNotificationForIntern(member.id_user, title, message, link);
|
||||
if (res.data) {
|
||||
results.push(res.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user