Add Signal and Whatsapp Docker CI

This commit is contained in:
Darren Clarke 2024-05-15 10:27:14 +02:00
parent b8ff61265b
commit 6305a8b0bc
12 changed files with 99 additions and 8 deletions

View file

@ -5,4 +5,9 @@ export { Edit } from "./components/Edit";
export { Detail } from "./components/Detail";
export { ServiceLayout } from "./components/ServiceLayout";
export { serviceConfig, getServiceTable } from "./config/config";
export { getBot, sendMessage, handleWebhook } from "./lib/routing";
export {
getBot,
sendMessage,
receiveMessage,
handleWebhook,
} from "./lib/routing";

View file

@ -12,6 +12,11 @@ export const sendMessage = async (
params: ServiceParams,
): Promise<NextResponse> => getService(params)?.sendMessage(req, params);
export const receiveMessage = async (
req: NextRequest,
params: ServiceParams,
): Promise<NextResponse> => getService(params)?.receiveMessage(req, params);
export const handleWebhook = async (
req: NextRequest,
params: ServiceParams,

View file

@ -82,6 +82,20 @@ export class Service {
return NextResponse.json({ response: "ok" });
}
async receiveMessage(
req: NextRequest,
{ params: { service, token } }: ServiceParams,
): Promise<NextResponse> {
const message = await req.json();
const worker = await getWorkerUtils();
await worker.addJob(`${service}/receive-${service}-message`, {
token,
message,
});
return NextResponse.json({ response: "ok" });
}
async handleWebhook(_req: NextRequest): Promise<NextResponse> {
return NextResponse.error() as any;
}