"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),error_1=require("@b/utils/error"),query_1=require("@b/utils/query");exports.metadata={summary:"Bulk updates the status of Posts",operationId:"bulkUpdatePostStatus",tags:["Content","Author","Post"],logModule:"BLOG",logTitle:"Bulk update post status",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",properties:{ids:{type:"array",description:"Array of Post IDs to update",items:{type:"string"}},status:{type:"string",enum:["PUBLISHED","DRAFT","TRASH"],description:"New status to apply to the Posts"}},required:["ids","status"]}}}},responses:(0,query_1.updateRecordResponses)("Post"),requiresAuth:!0};exports.default=async t=>{const{body:e,user:s,params:r,ctx:o}=t;if(!(null==s?void 0:s.id))throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"});const{ids:u,status:a}=e;null==o||o.step("Verifying author credentials");const d=await db_1.models.author.findOne({where:{userId:s.id}});if(!d)throw(0,error_1.createError)({statusCode:404,message:"Author not found"});null==o||o.step(`Updating ${u.length} post(s) to ${a}`);const i=await(0,query_1.updateStatus)("post",u,a,void 0,void 0,void 0,{authorId:d.id});null==o||o.success(`Updated ${u.length} post(s) to ${a} for author ${d.id}`);return i};