diff --git a/src/services/rabbitmq.ts b/src/services/rabbitmq.ts index 74df4dc0..0c18117c 100644 --- a/src/services/rabbitmq.ts +++ b/src/services/rabbitmq.ts @@ -445,11 +445,6 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise isSendNotification: true, })) : []; - /*เฉพาะคำสั่ง C-PM-10 ให้ตัด receiverUserId ที่ส่ง noti ครั้งแรกออก*/ - if (command && command.commandType && ["C-PM-10"].includes(command.commandType.code)) { - const firstNotiIds = profiles.map((p:any) => p.receiverUserId); - profilesSend = profilesSend.filter((x:any) => !firstNotiIds.includes(x.receiverUserId)); - } const payloadStr = await PayloadSendNoti(command.id); const profilesSendRequest = new CallAPI() .PostData( @@ -479,7 +474,14 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise console.error("Full error object:", error); }); - await Promise.all([profilesNotiRequest, profilesSendRequest]); + /*เฉพาะคำสั่ง C-PM-10 ให้ตัด profilesNotiRequest ที่ส่ง noti ครั้งแรกออก*/ + if (command && command.commandType && ["C-PM-10"].includes(command.commandType.code)) { + await Promise.all([profilesSendRequest]); + } + else { + await Promise.all([profilesNotiRequest, profilesSendRequest]); + } + console.log("[AMQ] Send Notification Success"); return true;