"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:"Deletes a specific post",operationId:"deletePost",tags:["Content","Author","Post"],logModule:"BLOG",logTitle:"Delete blog post",parameters:[{index:0,name:"id",in:"path",description:"ID of the post to delete",required:!0,schema:{type:"string"}},{name:"restore",in:"query",description:"Restore the post instead of deleting",required:!1,schema:{type:"boolean"}},{name:"force",in:"query",description:"Delete the post permanently",required:!1,schema:{type:"boolean"}}],responses:(0,query_1.deleteRecordResponses)("Post"),requiresAuth:!0};exports.default=async e=>{const{params:t,query:r,user:o,ctx:s}=e;if(!(null==o?void 0:o.id))throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"});null==s||s.step("Verifying author credentials");const i=await db_1.models.author.findOne({where:{userId:o.id}});if(!i)throw(0,error_1.createError)({statusCode:404,message:"Author not found"});null==s||s.step("Deleting post");const d=await(0,query_1.handleSingleDelete)({model:"post",id:t.id,query:r,where:{authorId:i.id}});null==s||s.success(`Post ${t.id} deleted by author ${i.id}`);return d};