/api/status only return meilisearch information when request is authorized

This commit is contained in:
2023-07-16 07:45:25 +08:00
parent 562795a4d1
commit feef87aff8

View File

@@ -5,20 +5,23 @@ import { return_data } from "../../server/utils.ts";
import { check_ffmpeg_binary } from "../../thumbnail/ffmpeg_binary.ts";
export const handler: Handlers = {
async GET(_req, _ctx) {
async GET(_req, ctx) {
const m = get_task_manager();
const is_authed = ctx.state.user !== undefined ||
m.db.get_user_count() === 0;
const ffmpeg_binary_enabled = await check_ffmpeg_binary(
m.cfg.ffmpeg_path,
);
const meilisearch_enabled = m.meilisearch !== undefined;
const meilisearch = meilisearch_enabled && m.cfg.meili_host &&
const meilisearch =
is_authed && meilisearch_enabled && m.cfg.meili_host &&
m.cfg.meili_update_api_key
? {
host: m.cfg.meili_host,
key: m.cfg.meili_search_api_key ||
m.cfg.meili_update_api_key,
}
: undefined;
? {
host: m.cfg.meili_host,
key: m.cfg.meili_search_api_key ||
m.cfg.meili_update_api_key,
}
: undefined;
const no_user = m.db.get_user_count() === 0;
return return_data<StatusData>({
ffmpeg_binary_enabled,