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

@ -2,20 +2,28 @@ import { db, getWorkerUtils } from "@link-stack/bridge-common";
interface ReceiveSignalMessageTaskOptions {
token: string;
sender: string;
to: string;
from: string;
messageId: string;
sentAt: string;
message: string;
messageID: string;
timestamp: string;
attachment?: string;
filename?: string;
mimeType?: string;
}
const receiveSignalMessageTask = async ({
token,
sender,
to,
from,
messageId,
sentAt,
message,
messageID,
timestamp,
attachment,
filename,
mimeType,
}: ReceiveSignalMessageTaskOptions): Promise<void> => {
console.log({ token, sender, message, messageID, timestamp });
console.log({ token, to, from });
const worker = await getWorkerUtils();
const row = await db
.selectFrom("SignalBot")
@ -23,15 +31,16 @@ const receiveSignalMessageTask = async ({
.where("id", "=", token)
.executeTakeFirstOrThrow();
console.log(row);
console.log(message);
const backendId = row.id;
const payload = {
to: row.phoneNumber,
from: sender,
sent_at: timestamp,
to,
from,
message_id: messageId,
sent_at: sentAt,
message,
message_id: messageID,
attachment,
filename,
mime_type: mimeType,
};
await worker.addJob("common/notify-webhooks", { backendId, payload });