feat: Nambahin feature notifikasi
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const projectRepository = require("../repositories/project.repository");
|
||||
const notificationService = require("../../notification/services/notification.service");
|
||||
const { data, error } = require("../../../helpers/utils/wrapper");
|
||||
const {
|
||||
BadRequestError,
|
||||
@@ -86,6 +87,14 @@ class ProjectService {
|
||||
userIds,
|
||||
);
|
||||
|
||||
for (const idUser of userIds) {
|
||||
await notificationService.createNotificationForIntern(
|
||||
idUser,
|
||||
"Diterima ke Proyek",
|
||||
`Anda telah bergabung ke proyek '${project.project_name}'.`
|
||||
).catch(err => console.error("Failed to send project assignment notification:", err));
|
||||
}
|
||||
|
||||
return data(this.mapProjectDetail(project));
|
||||
} catch (err) {
|
||||
return error(err);
|
||||
@@ -516,6 +525,12 @@ class ProjectService {
|
||||
membership = await projectRepository.assignMember(id_project, id_user);
|
||||
}
|
||||
|
||||
await notificationService.createNotificationForIntern(
|
||||
id_user,
|
||||
"Diterima ke Proyek",
|
||||
`Anda telah bergabung ke proyek '${project.project_name}'.`
|
||||
).catch(err => console.error("Failed to send project assignment notification:", err));
|
||||
|
||||
return data(membership);
|
||||
} catch (err) {
|
||||
return error(err);
|
||||
|
||||
Reference in New Issue
Block a user