| @@ -8,7 +8,28 @@ import { · 7 unmodified lines |
| 8 | 8 | import { getExtractQueue } from "../../services/queue-service"; |
| 9 | 9 | import * as Sentry from "@sentry/node"; |
| 10 | 10 | import { saveExtract } from "../../lib/extract/extract-redis"; |
| 11 | +import { getTeamIdSyncB } from "../../lib/extract/team-id-sync"; |
| 12 | +import { performExtraction } from "../../lib/extract/extraction-service"; |
| 11 | 13 | |
| 14 | +export async function oldExtract(req: RequestWithAuth<{}, ExtractResponse, ExtractRequest>, res: Response<ExtractResponse>, extractId: string){ |
| 15 | + // Means that are in the non-queue system |
| 16 | + // TODO: Remove this once all teams have transitioned to the new system |
| 17 | + try { |
| 18 | + const result = await performExtraction(extractId, { |
| 19 | + request: req.body, |
| 20 | + teamId: req.auth.team_id, |
| 21 | + plan: req.auth.plan ?? "free", |
| 22 | + subId: req.acuc?.sub_id ?? undefined, |
| 23 | + }); |
| 24 | + |
| 25 | + return res.status(200).json(result); |
| 26 | + } catch (error) { |
| 27 | + return res.status(500).json({ |
| 28 | + success: false, |
| 29 | + error: "Internal server error", |
| 30 | + }); |
| 31 | + } |
| 32 | + } |
| 12 | 33 | /** |
| 13 | 34 | * Extracts data from the provided URLs based on the request parameters. |
| 14 | 35 | * Currently in beta. |
| @@ -32,6 +53,10 @@ export async function extractController( · 17 unmodified lines |
| 32 | 53 | extractId, |
| 33 | 54 | }; |
| 34 | 55 | |
| 56 | + if(await getTeamIdSyncB(req.auth.team_id) && req.body.origin !== "api-sdk") { |
| 57 | + return await oldExtract(req, res, extractId); |
| 58 | + } |
| 59 | + |
| 35 | 60 | await saveExtract(extractId, { |
| 36 | 61 | id: extractId, |
| 37 | 62 | team_id: req.auth.team_id, |