diff --git a/api/inbox/index.ts b/api/inbox/index.ts index d7be515f..954c1b35 100644 --- a/api/inbox/index.ts +++ b/api/inbox/index.ts @@ -66,7 +66,7 @@ export default apiRoute((app) => }); return context.newResponse( - "Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual errors", + "Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)", 200, ); }), diff --git a/api/users/:uuid/inbox/index.ts b/api/users/:uuid/inbox/index.ts index 4942e8ec..4d9eeeb8 100644 --- a/api/users/:uuid/inbox/index.ts +++ b/api/users/:uuid/inbox/index.ts @@ -1,15 +1,9 @@ import { apiRoute, applyConfig } from "@/api"; import { createRoute } from "@hono/zod-openapi"; import type { Entity } from "@versia/federation/types"; -import type { Job } from "bullmq"; import { z } from "zod"; import { ErrorSchema } from "~/types/api"; -import { - type InboxJobData, - InboxJobType, - inboxQueue, - inboxWorker, -} from "~/worker"; +import { InboxJobType, inboxQueue } from "~/worker"; export const meta = applyConfig({ auth: { @@ -111,7 +105,7 @@ export default apiRoute((app) => app.openapi(route, async (context) => { const body: Entity = await context.req.valid("json"); - const result = await inboxQueue.add(InboxJobType.ProcessEntity, { + await inboxQueue.add(InboxJobType.ProcessEntity, { data: body, headers: context.req.valid("header"), request: { @@ -122,31 +116,9 @@ export default apiRoute((app) => ip: context.env.ip ?? null, }); - return new Promise((resolve, reject) => { - const successCallback = ( - job: Job, - ): void => { - if (job.id === result.id) { - inboxWorker.off("completed", successCallback); - inboxWorker.off("failed", failureCallback); - resolve(job.returnvalue); - } - }; - - const failureCallback = ( - job: Job | undefined, - error: Error, - ): void => { - if (job && job.id === result.id) { - inboxWorker.off("completed", successCallback); - inboxWorker.off("failed", failureCallback); - reject(error); - } - }; - - inboxWorker.on("completed", successCallback); - - inboxWorker.on("failed", failureCallback); - }); + return context.newResponse( + "Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)", + 200, + ); }), );