mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Add new api
This commit is contained in:
25
routes/api/task/download_cfg.ts
Normal file
25
routes/api/task/download_cfg.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { User, UserPermission } from "../../../db.ts";
|
||||
import { get_task_manager } from "../../../server.ts";
|
||||
import { return_data, return_error } from "../../../server/utils.ts";
|
||||
import type { DownloadConfig } from "../../../tasks/download.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(_req, ctx) {
|
||||
const user = <User | undefined> ctx.state.user;
|
||||
if (
|
||||
user && !user.is_admin &&
|
||||
!(user.permissions & UserPermission.ManageTasks)
|
||||
) {
|
||||
return return_error(403, "Permission denied.");
|
||||
}
|
||||
const m = get_task_manager();
|
||||
return return_data<DownloadConfig>({
|
||||
download_original_img: m.cfg.download_original_img,
|
||||
max_download_img_count: m.cfg.max_download_img_count,
|
||||
max_retry_count: m.cfg.max_retry_count,
|
||||
mpv: m.cfg.mpv,
|
||||
remove_previous_gallery: m.cfg.remove_previous_gallery,
|
||||
});
|
||||
},
|
||||
};
|
||||
21
routes/api/task/export_zip_cfg.ts
Normal file
21
routes/api/task/export_zip_cfg.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { User, UserPermission } from "../../../db.ts";
|
||||
import { get_task_manager } from "../../../server.ts";
|
||||
import { return_data, return_error } from "../../../server/utils.ts";
|
||||
import type { ExportZipConfig } from "../../../tasks/export_zip.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(_req, ctx) {
|
||||
const user = <User | undefined> ctx.state.user;
|
||||
if (
|
||||
user && !user.is_admin &&
|
||||
!(user.permissions & UserPermission.ManageTasks)
|
||||
) {
|
||||
return return_error(403, "Permission denied.");
|
||||
}
|
||||
const m = get_task_manager();
|
||||
return return_data<ExportZipConfig>({
|
||||
jpn_title: m.cfg.export_zip_jpn_title,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user