noti report

This commit is contained in:
kittapath 2024-10-18 18:08:08 +07:00
parent 5bf3beb30b
commit d4437c8640

View file

@ -1004,7 +1004,7 @@ export class CommandController extends Controller {
) {
const command = await this.commandRepository.findOne({
where: { id: id },
relations: ["commandType", "commandRecives"],
relations: ["commandType", "commandRecives", "commandSends", "commandSends.commandSendCCs"],
});
if (!command) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลคำสั่งนี้");
@ -1036,6 +1036,29 @@ export class CommandController extends Controller {
.catch((error) => {
console.error("Error calling API:", error);
});
let _profiles =
command && command.commandSends.length > 0
? command.commandSends
.filter((x) => x.profileId != null)
.map((x) => ({
receiverUserId: x.profileId,
notiLink: "",
isSendMail: x.commandSendCCs.map((x) => x.name == "EMAIL").length > 0 ? true : false,
isSendInbox: x.commandSendCCs.map((x) => x.name == "INBOX").length > 0 ? true : false,
isSendNotification: true,
}))
: [];
await new CallAPI()
.PostData(request, "/placement/noti/profiles", {
subject: `${command.issue}`,
body: `${command.issue}`,
receiverUserIds: _profiles,
payload: "", //แนบไฟล์
})
.catch((error) => {
console.error("Error calling API:", error);
});
if (
new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()) <
new Date(