From baa5a99855fed681de5d107696c5a9bfd7ef8999 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 23 Oct 2024 13:42:05 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Removed=20indirection=20for=20ge?= =?UTF-8?q?tBundles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/library.service.ts | 24 +++++++++++++----------- services/socket.service.ts | 11 ----------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/services/library.service.ts b/services/library.service.ts index 6368bd1..b560d43 100644 --- a/services/library.service.ts +++ b/services/library.service.ts @@ -51,6 +51,7 @@ const through2 = require("through2"); import klaw from "klaw"; import path from "path"; import { COMICS_DIRECTORY, USERDATA_DIRECTORY } from "../constants/directories"; +import AirDCPPSocket from "../shared/airdcpp.socket"; console.log(`MONGO -> ${process.env.MONGO_URI}`); export default class ImportService extends Service { @@ -707,6 +708,11 @@ export default class ImportService extends Service { }; }, }, + + + // This method belongs in library service, + // because bundles can only exist for comics _in the library_ + // (wanted or imported) getBundles: { rest: "POST /getBundles", params: {}, @@ -717,30 +723,26 @@ export default class ImportService extends Service { }> ) => { // 1. Get the comic object Id - console.log("ala re lala"); - console.log(ctx.params); const { config } = ctx.params; const comicObject = await Comic.findById( new ObjectId(ctx.params.comicObjectId) ); - console.log(JSON.stringify(comicObject, null, 4)); - + // 2. Init AirDC++ + // 3. Get the bundles for the comic object + const ADCPPSocket = new AirDCPPSocket(config); if (comicObject) { const foo = comicObject.acquisition.directconnect.downloads.map( async (bundle) => { // make the call to get the bundles from AirDC++ using the bundleId - return await this.broker.call("socket.getBundles", { - bundleId: bundle.id, - config, - }); + return await ADCPPSocket.get(`queue/bundles/${bundle.id}`); } ); - console.log(foo); + return foo; } - return []; + return false; + }, }, - flushDB: { rest: "POST /flushDB", params: {}, diff --git a/services/socket.service.ts b/services/socket.service.ts index 53b6c67..d7d704d 100644 --- a/services/socket.service.ts +++ b/services/socket.service.ts @@ -104,18 +104,7 @@ export default class SocketService extends Service { // {} // ); }, - // AirDCPP Socket actions - // the way this method is called has some unnecessary indirection - getBundles: { - rest: "GET /getBundles", - handler: async (ctx: Context<{ config: any; bundleId: string }>) => { - const { config, bundleId } = ctx.params; - console.log(config); - const ADCPPSocket = new AirDCPPSocket(config); - return await ADCPPSocket.get(`queue/bundles/${bundleId}`); - }, - }, search: { params: { query: "object",