mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Add new API
This commit is contained in:
31
routes/api/task/import_cfg.ts
Normal file
31
routes/api/task/import_cfg.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { ImportMethod } from "../../../config.ts";
|
||||
import { User, UserPermission } from "../../../db.ts";
|
||||
import { get_task_manager } from "../../../server.ts";
|
||||
import { return_data, return_error } from "../../../server/utils.ts";
|
||||
|
||||
export type DefaultImportConfig = {
|
||||
max_import_img_count?: number;
|
||||
mpv?: boolean;
|
||||
method?: ImportMethod;
|
||||
remove_previous_gallery?: boolean;
|
||||
};
|
||||
|
||||
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<DefaultImportConfig>({
|
||||
max_import_img_count: m.cfg.max_import_img_count,
|
||||
method: m.cfg.import_method,
|
||||
mpv: m.cfg.mpv,
|
||||
remove_previous_gallery: m.cfg.remove_previous_gallery,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user