🔧 Removed indirection for getBundles
This commit is contained in:
@@ -51,6 +51,7 @@ const through2 = require("through2");
|
|||||||
import klaw from "klaw";
|
import klaw from "klaw";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { COMICS_DIRECTORY, USERDATA_DIRECTORY } from "../constants/directories";
|
import { COMICS_DIRECTORY, USERDATA_DIRECTORY } from "../constants/directories";
|
||||||
|
import AirDCPPSocket from "../shared/airdcpp.socket";
|
||||||
|
|
||||||
console.log(`MONGO -> ${process.env.MONGO_URI}`);
|
console.log(`MONGO -> ${process.env.MONGO_URI}`);
|
||||||
export default class ImportService extends Service {
|
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: {
|
getBundles: {
|
||||||
rest: "POST /getBundles",
|
rest: "POST /getBundles",
|
||||||
params: {},
|
params: {},
|
||||||
@@ -717,30 +723,26 @@ export default class ImportService extends Service {
|
|||||||
}>
|
}>
|
||||||
) => {
|
) => {
|
||||||
// 1. Get the comic object Id
|
// 1. Get the comic object Id
|
||||||
console.log("ala re lala");
|
|
||||||
console.log(ctx.params);
|
|
||||||
const { config } = ctx.params;
|
const { config } = ctx.params;
|
||||||
const comicObject = await Comic.findById(
|
const comicObject = await Comic.findById(
|
||||||
new ObjectId(ctx.params.comicObjectId)
|
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) {
|
if (comicObject) {
|
||||||
const foo = comicObject.acquisition.directconnect.downloads.map(
|
const foo = comicObject.acquisition.directconnect.downloads.map(
|
||||||
async (bundle) => {
|
async (bundle) => {
|
||||||
// make the call to get the bundles from AirDC++ using the bundleId
|
// make the call to get the bundles from AirDC++ using the bundleId
|
||||||
return await this.broker.call("socket.getBundles", {
|
return await ADCPPSocket.get(`queue/bundles/${bundle.id}`);
|
||||||
bundleId: bundle.id,
|
|
||||||
config,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
console.log(foo);
|
return foo;
|
||||||
}
|
}
|
||||||
return [];
|
return false;
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
flushDB: {
|
flushDB: {
|
||||||
rest: "POST /flushDB",
|
rest: "POST /flushDB",
|
||||||
params: {},
|
params: {},
|
||||||
|
|||||||
@@ -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: {
|
search: {
|
||||||
params: {
|
params: {
|
||||||
query: "object",
|
query: "object",
|
||||||
|
|||||||
Reference in New Issue
Block a user