Standardize bridge send/receive params

This commit is contained in:
Darren Clarke 2024-07-18 11:08:01 +02:00
parent 69abe9bee1
commit c32c26088f
23 changed files with 7042 additions and 1276 deletions

View file

@ -4,15 +4,16 @@ const { Configuration, MessagesApi } = signalApi;
interface SendSignalMessageTaskOptions {
token: string;
recipient: string;
to: string;
message: any;
}
const sendSignalMessageTask = async ({
message,
recipient,
token,
to,
message,
}: SendSignalMessageTaskOptions): Promise<void> => {
console.log({ token, to });
const bot = await db
.selectFrom("SignalBot")
.selectAll()
@ -24,15 +25,20 @@ const sendSignalMessageTask = async ({
basePath: process.env.BRIDGE_SIGNAL_URL,
});
const messagesClient = new MessagesApi(config);
const response = await messagesClient.v2SendPost({
data: {
number,
recipients: [recipient],
message,
},
});
console.log({ response });
try {
const response = await messagesClient.v2SendPost({
data: {
number,
recipients: [to],
message,
},
});
console.log({ response });
} catch (error) {
console.error({ error });
throw error;
}
};
export default sendSignalMessageTask;