Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
uriva committed Oct 7, 2024
1 parent cbefe5b commit b8dbae2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/greenApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { gamla } from "../deps.ts";
// @ts-expect-error no types
import greenApi from "npm:@green-api/whatsapp-api-client@0.4.0-0";

const { pipe, replace } = gamla;
const { pipe, replace, identity } = gamla;

import {
injectBotPhone,
Expand Down Expand Up @@ -105,7 +105,7 @@ const communications = <T extends TaskHandler>(
api: ReturnType<typeof greenApi.restAPI>,
botPhone: string,
msgId: string,
referenceId: string,
referenceId: string | undefined,
userId: string,
send: (txt: string) => Promise<string>,
) =>
Expand All @@ -118,7 +118,7 @@ const communications = <T extends TaskHandler>(
injectSendFile((url: string) =>
api.file.sendFileByUrl(userId, null, url, "video.mp4", "")
)<T>,
injectReferenceId(() => referenceId)<T>,
referenceId ? injectReferenceId(() => referenceId)<T> : identity,
injectSpinner(pipe(send, (_) => () => Promise.resolve()))<T>,
injectReply(send)<T>,
);
Expand Down Expand Up @@ -149,7 +149,7 @@ export const greenApiHandler = (
greenApi.restAPI(credentials),
rewriteNumber(msg.instanceData.wid),
msg.idMessage,
greenApiReferenceId(msg) ?? "",
greenApiReferenceId(msg),
messageSender(msg),
sendGreenApiMessage(credentials)(messageSender(msg)),
)(doTask)({ text: messageText(msg) }),
Expand Down
5 changes: 4 additions & 1 deletion src/whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
filter,
join,
coerce,
identity,
letIn,
pipe,
empty,
Expand Down Expand Up @@ -323,7 +324,9 @@ export const whatsappBusinessHandler = (
injectUserId(() => coerce(fromNumber(msg))),
injectSpinner(pipe(send, (_) => () => Promise.resolve())),
injectReply(send),
injectReferenceId(() => referenceId(msg)),
referenceId(msg)
? injectReferenceId(() => referenceId(msg))
: identity,
) as RetainsType,
)(doTask)({ ...getText(msg), ...getContacts(msg) })
: Promise.resolve(),
Expand Down

0 comments on commit b8dbae2

Please sign in to comment.