tambahan
This commit is contained in:
@@ -29,6 +29,8 @@ async function sendReplyMessage(to: string, message: string, phoneNumberId: stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const allowedTypeMessage = ["text"]
|
||||||
|
|
||||||
const WaHookRoute = new Elysia({
|
const WaHookRoute = new Elysia({
|
||||||
prefix: "/wa-hook",
|
prefix: "/wa-hook",
|
||||||
tags: ["WhatsApp Hook"],
|
tags: ["WhatsApp Hook"],
|
||||||
@@ -165,15 +167,16 @@ const WaHookRoute = new Elysia({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const count = await prisma.waHook.count()
|
const count = await prisma.waHook.count()
|
||||||
const result = list.map((item) => ({
|
const result = list.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
data: item.data as WAHookMessage,
|
data: item.data as WAHookMessage,
|
||||||
createdAt: item.createdAt,
|
createdAt: item.createdAt,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const filterData = result.filter((item) => allowedTypeMessage.includes(item.data?.entry?.[0]?.changes?.[0]?.value?.messages?.[0]?.type || ""))
|
||||||
return {
|
return {
|
||||||
list: result,
|
list: filterData,
|
||||||
count: Math.ceil(count / (query.limit || 10)),
|
count: Math.ceil(count / (query.limit || 10)),
|
||||||
};
|
};
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
type TYPE = "image" | "video" | "audio" | "file" | "text" | "sticker" | "document"
|
type TYPE_MESSAGE = "image" | "video" | "audio" | "file" | "text" | "sticker" | "document"
|
||||||
const message = {
|
const message = {
|
||||||
"object": "whatsapp_business_account",
|
"object": "whatsapp_business_account",
|
||||||
"entry": [
|
"entry": [
|
||||||
@@ -28,7 +28,7 @@ const message = {
|
|||||||
"text": {
|
"text": {
|
||||||
"body": "halo"
|
"body": "halo"
|
||||||
},
|
},
|
||||||
"type": "text" as TYPE
|
"type": "text" as TYPE_MESSAGE
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user