mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
update shields
This commit is contained in:
9
dashboard/server/api/shields/bots/options.ts
Normal file
9
dashboard/server/api/shields/bots/options.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { BotTrafficOptionModel } from "~/shared/schema/shields/BotTrafficOptionSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
const result = await BotTrafficOptionModel.findOne({ project_id: data.project_id });
|
||||
if (!result) return { block: false };
|
||||
return { block: result.block }
|
||||
});
|
||||
14
dashboard/server/api/shields/bots/update_options.post.ts
Normal file
14
dashboard/server/api/shields/bots/update_options.post.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { BotTrafficOptionModel } from "~/shared/schema/shields/BotTrafficOptionSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
const body = await readBody(event);
|
||||
const { block } = body;
|
||||
|
||||
if (block != true && block != false)
|
||||
return setResponseStatus(event, 400, 'block is required and must be true or false');
|
||||
|
||||
const result = await BotTrafficOptionModel.updateOne({ project_id: data.project_id }, { block }, { upsert: true });
|
||||
return { ok: result.acknowledged };
|
||||
});
|
||||
11
dashboard/server/api/shields/countries/add.post.ts
Normal file
11
dashboard/server/api/shields/countries/add.post.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { CountryBlacklistModel } from "~/shared/schema/shields/CountryBlacklistSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
const body = await readBody(event);
|
||||
const { country, description } = body;
|
||||
if (country.trim().length == 0) return setResponseStatus(event, 400, 'Country is required');
|
||||
const result = await CountryBlacklistModel.updateOne({ project_id: data.project_id, country }, { description }, { upsert: true });
|
||||
return { ok: result.acknowledged };
|
||||
});
|
||||
14
dashboard/server/api/shields/countries/delete.delete.ts
Normal file
14
dashboard/server/api/shields/countries/delete.delete.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { CountryBlacklistModel } from "~/shared/schema/shields/CountryBlacklistSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
|
||||
const body = await readBody(event);
|
||||
const { country } = body;
|
||||
|
||||
const removal = await CountryBlacklistModel.deleteOne({ project_id: data.project_id, country });
|
||||
|
||||
return { ok: removal.deletedCount == 1 };
|
||||
});
|
||||
8
dashboard/server/api/shields/countries/list.ts
Normal file
8
dashboard/server/api/shields/countries/list.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { CountryBlacklistModel } from "~/shared/schema/shields/CountryBlacklistSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
const blacklist = await CountryBlacklistModel.find({ project_id: data.project_id });
|
||||
return blacklist.map(e => e.toJSON());
|
||||
});
|
||||
Reference in New Issue
Block a user