import "../../../../../after-B1IIdH3Y.mjs";
import "../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import "../../../../../comment-CzeatwBV.mjs";
import { a as unwrapResult, i as requireDb, r as handleError } from "../../../../../error-CkAseSqZ.mjs";
import { n as parseBody, t as isParseError } from "../../../../../parse-GmjecGct.mjs";
import { pt as commentBulkBody } from "../../../../../redirects-DXEXBAII.mjs";
import "../../../../../byline-fields-2Lp5Hbgf.mjs";
import "../../../../../status-CqJQX1QN.mjs";
import "../../../../../api/schemas/index.mjs";
import { n as requirePerm } from "../../../../../authorize-Dz88F_Fw.mjs";
import { n as handleCommentBulk } from "../../../../../comments-BLE-jv5k.mjs";

//#region src/astro/routes/api/admin/comments/bulk.ts
const prerender = false;
const POST = async ({ request, locals }) => {
	const { emdash, user } = locals;
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	try {
		const body = await parseBody(request, commentBulkBody);
		if (isParseError(body)) return body;
		if (body.action === "delete") {
			const denied = requirePerm(user, "comments:delete");
			if (denied) return denied;
		} else {
			const denied = requirePerm(user, "comments:moderate");
			if (denied) return denied;
		}
		return unwrapResult(await handleCommentBulk(emdash.db, body.ids, body.action));
	} catch (error) {
		return handleError(error, "Failed to perform bulk operation", "COMMENT_BULK_ERROR");
	}
};

//#endregion
export { POST, prerender };
//# sourceMappingURL=bulk.mjs.map