diff --git a/functions/api/manage/_middleware.js b/functions/api/manage/_middleware.js index 2d1a22f8d..edd1085db 100644 --- a/functions/api/manage/_middleware.js +++ b/functions/api/manage/_middleware.js @@ -71,8 +71,8 @@ async function errorHandling(context) { //context.env.BASIC_USER="admin" //context.env.BASIC_PASS="admin" //check if the env variables Disable_Dashboard are set - if (context.env.DISABLE_DASHBOARD == "true") { - return new Response('Dashboard is disabled. Please enable to use this feature.', { status: 200 }); + if (typeof context.env.img_url == "undefined" || context.env.img_url == null || context.env.img_url == "") { + return new Response('Dashboard is disabled. Please bind a KV namespace to use this feature.', { status: 200 }); } console.log(context.env.BASIC_USER) diff --git a/functions/file/[id].js b/functions/file/[id].js index 671f3dc6c..7b94d6252 100644 --- a/functions/file/[id].js +++ b/functions/file/[id].js @@ -23,9 +23,8 @@ export async function onRequest(context) { // Contents of context object //show the image return response; } - console.log("env.Disable_Dashboard:") - console.log(env.Disable_Dashboard) - if (env.Disable_Dashboard){}else{ + + if (env.img_url){}else{ //check the record from kv const record = await env.img_url.getWithMetadata(params.id); console.log(record) @@ -36,6 +35,8 @@ export async function onRequest(context) { // Contents of context object return response; }else if (record.metadata.ListType=="Block"){ return Response.redirect(url.origin+"/block-img.html", 302) + }else if (record.metadata.Label=="adult"){ + return Response.redirect(url.origin+"/block-img.html", 302) } //check if the env variables WhiteList_Mode are set if (env.WhiteList_Mode=="true"){ @@ -52,9 +53,8 @@ export async function onRequest(context) { // Contents of context object let apikey=env.ModerateContentApiKey if(typeof apikey == "undefined" || apikey == null || apikey == ""){ - //check if the env variables Disable_Dashboard are set - if (env.Disable_Dashboard){console.log(1)}else{ + if (env.img_url){console.log(1)}else{ //add image to kv await env.img_url.put(params.id, "",{ metadata: { ListType: "None", rating_label: "None",TimeStamp: time }, @@ -65,7 +65,7 @@ export async function onRequest(context) { // Contents of context object then(async (response) => { let moderate_data = await response.json(); console.log(moderate_data) - if (env.Disable_Dashboard=="true"){}else{ + if (env.img_url=="true"){}else{ //add image to kv await env.img_url.put(params.id, "",{ metadata: { ListType: "None", Label: moderate_data.rating_label,TimeStamp: time },