"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const utils_1=require("./utils"),query_1=require("@b/utils/query"),utils_2=require("./utils"),Websocket_1=require("@b/handler/Websocket");exports.metadata={summary:"Stores a new Announcement",operationId:"storeAnnouncement",tags:["Admin","Announcements"],requestBody:{required:!0,content:{"application/json":{schema:utils_1.announcementUpdateSchema}}},responses:(0,query_1.storeRecordResponses)(utils_2.announcementSchema,"Announcement"),requiresAuth:!0,permission:"create.announcement",logModule:"ADMIN_SYS",logTitle:"Create announcement"};exports.default=async e=>{const{body:n,ctx:t}=e,{type:s,title:a,message:o,link:u,status:r}=n;null==t||t.step("Validating announcement data");null==t||t.step("Creating announcement");const c=await(0,query_1.storeRecord)({model:"announcement",data:{type:s,title:a,message:o,link:u,status:r},returnResponse:!0});null==t||t.step("Broadcasting announcement creation");(0,Websocket_1.handleBroadcastMessage)({type:"announcements",method:"create",data:c.record});null==t||t.success("Announcement created successfully");return c.message};