Skip to content

Commit ed533fd

Browse files
committed
bgfx
1 parent e4d44ad commit ed533fd

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/whatsapp.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
letIn,
2727
pipe,
2828
empty,
29+
nonempty,
2930
map,
3031
replace,
3132
juxtCat,
@@ -233,8 +234,8 @@ type WebhookVerification = {
233234
const innerMessageTypeEquals = (y: string) => (x: InnerMessage) =>
234235
"type" in x && x.type === y;
235236

236-
const innerMessages = (message: WhatsappMessage) =>
237-
message.entry[0].changes[0].value.messages || [];
237+
const innerMessages = (msg: WhatsappMessage) =>
238+
msg.entry[0].changes[0].value.messages || [];
238239

239240
const fromNumber = pipe(
240241
innerMessages,
@@ -243,7 +244,6 @@ const fromNumber = pipe(
243244

244245
const messageId = pipe(
245246
innerMessages,
246-
filter((x: InnerMessage) => x.type === "reaction"),
247247
(msgs: InnerMessage[]) => msgs[0].id,
248248
);
249249

@@ -365,13 +365,11 @@ const getContacts = (
365365

366366
export const whatsappForBusinessInjectDepsAndRun =
367367
(token: string, doTask: TaskHandler) => async (msg: WhatsappMessage) =>
368-
msg.entry[0].changes[0].value.messages
368+
nonempty(innerMessages(msg))
369369
? letIn(
370370
{
371371
event: { ...await getText(token)(msg), ...getContacts(msg) },
372-
send: sendWhatsappMessage(token, toNumberId(msg))(
373-
coerce(fromNumber(msg)),
374-
),
372+
send: sendWhatsappMessage(token, toNumberId(msg))(fromNumber(msg)),
375373
},
376374
({ send, event }) =>
377375
pipe(

0 commit comments

Comments
 (0)