"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const db_1=require("@b/db"),error_1=require("@b/utils/error");exports.metadata={summary:"Get user block history",description:"Retrieve the block history for a specific user",operationId:"getUserBlocks",tags:["Admin","CRM","User"],parameters:[{index:0,name:"id",in:"path",required:!0,description:"ID of the user",schema:{type:"string"}}],responses:{200:{description:"User block history retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{data:{type:"array",items:{type:"object",properties:{id:{type:"string"},reason:{type:"string"},isTemporary:{type:"boolean"},duration:{type:"number"},blockedUntil:{type:"string"},isActive:{type:"boolean"},createdAt:{type:"string"},admin:{type:"object",properties:{firstName:{type:"string"},lastName:{type:"string"},email:{type:"string"}}}}}}}}}}},401:{description:"Unauthorized"},404:{description:"User not found"}},requiresAuth:!0,permission:"view.user",demoMask:["data.admin.email"],logModule:"ADMIN_CRM",logTitle:"Get User Blocks"};exports.default=async e=>{const{params:r,user:t,ctx:s}=e,{id:i}=r;if(!(null==t?void 0:t.id))throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"});null==s||s.step("Checking user existence");if(!await db_1.models.user.findByPk(i))throw(0,error_1.createError)({statusCode:404,message:"User not found"});null==s||s.step("Fetching user block history");const o=await db_1.models.userBlock.findAll({where:{userId:i},include:[{model:db_1.models.user,as:"admin",attributes:["firstName","lastName","email"]}],order:[["createdAt","DESC"]]});null==s||s.success("User block history retrieved successfully");return{data:o}};