refactor: filter to registered user
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
This commit is contained in:
parent
95fc06ce5f
commit
db4d21bb62
1 changed files with 43 additions and 37 deletions
|
|
@ -68,12 +68,10 @@ export class WebHookController extends Controller {
|
||||||
const userIdLine = payload.events[0]?.source?.userId;
|
const userIdLine = payload.events[0]?.source?.userId;
|
||||||
const dataNow = dayjs().tz("Asia/Bangkok").startOf("day");
|
const dataNow = dayjs().tz("Asia/Bangkok").startOf("day");
|
||||||
|
|
||||||
// const dataUser = await prisma.customerBranch.findFirst({
|
if (payload?.events[0]?.message) {
|
||||||
// where:{
|
const message = payload.events[0].message.text;
|
||||||
// userId:userIdLine
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
|
if (message === "เมนูหลัก > ข้อความ") {
|
||||||
const dataEmployee = await prisma.employeePassport.findMany({
|
const dataEmployee = await prisma.employeePassport.findMany({
|
||||||
select: {
|
select: {
|
||||||
firstName: true,
|
firstName: true,
|
||||||
|
|
@ -109,6 +107,18 @@ export class WebHookController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
|
employee: {
|
||||||
|
customerBranch: {
|
||||||
|
OR: [
|
||||||
|
{ userId: userIdLine },
|
||||||
|
{
|
||||||
|
customer: {
|
||||||
|
branch: { some: { userId: userIdLine } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
expireDate: {
|
expireDate: {
|
||||||
lt: dataNow.add(30, "day").toDate(),
|
lt: dataNow.add(30, "day").toDate(),
|
||||||
},
|
},
|
||||||
|
|
@ -118,10 +128,6 @@ export class WebHookController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (payload?.events[0]?.message) {
|
|
||||||
const message = payload.events[0].message.text;
|
|
||||||
|
|
||||||
if (message === "เมนูหลัก > ข้อความ") {
|
|
||||||
const dataUser = userIdLine;
|
const dataUser = userIdLine;
|
||||||
const textHead = "JWS ALERT:";
|
const textHead = "JWS ALERT:";
|
||||||
let textData = "";
|
let textData = "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue