"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const query_1=require("@b/utils/query"),utils_1=require("../utils"),Websocket_1=require("@b/handler/Websocket");exports.metadata={summary:"Updates a specific Announcement",operationId:"updateAnnouncement",tags:["Admin","Announcements"],parameters:[{index:0,name:"id",in:"path",description:"ID of the Announcement to update",required:!0,schema:{type:"string"}}],requestBody:{description:"New data for the Announcement",content:{"application/json":{schema:utils_1.announcementUpdateSchema}}},responses:(0,query_1.updateRecordResponses)("Announcement"),requiresAuth:!0,permission:"edit.announcement",logModule:"ADMIN_SYS",logTitle:"Update announcement"};exports.default=async e=>{const{body:n,params:t,ctx:a}=e,{id:s}=t,{type:u,title:o,message:c,link:d,status:i}=n;null==a||a.step("Validating announcement data");null==a||a.step(`Updating announcement ${s}`);const r=await(0,query_1.updateRecord)("announcement",s,{type:u,title:o,message:c,link:d,status:i});null==a||a.step("Broadcasting announcement update");(0,Websocket_1.handleBroadcastMessage)({type:"announcements",model:"announcement",method:"update",data:{type:u,title:o,message:c,link:d,status:i},id:s});null==a||a.success("Announcement updated successfully");return r};