"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:"Delete a Notification",description:"Deletes the specified notification for the authenticated creator.",operationId:"deleteNotification",tags:["ICO","Creator","Notifications"],requiresAuth:!0,logModule:"USER",logTitle:"Delete notification",parameters:[{index:0,name:"id",in:"path",description:"Notification ID",required:!0,schema:{type:"string"}}],responses:{200:{description:"Notification deleted successfully."},401:{description:"Unauthorized"},404:{description:"Notification not found"},500:{description:"Internal Server Error"}}};exports.default=async e=>{const{user:t,params:i,ctx:o}=e;if(!(null==t?void 0:t.id)){null==o||o.fail("User not authenticated");throw(0,error_1.createError)({statusCode:401,message:"Unauthorized"})}const r=i.id;if(!r){null==o||o.fail("Notification ID missing");throw(0,error_1.createError)({statusCode:400,message:"Notification ID is required"})}null==o||o.step("Finding notification");const s=await db_1.models.notification.findOne({where:{id:r,userId:t.id}});if(!s){null==o||o.fail("Notification not found");throw(0,error_1.createError)({statusCode:404,message:"Notification not found"})}null==o||o.step("Deleting notification");await s.destroy({force:!0});null==o||o.success("Notification deleted successfully");return{message:"Notification deleted successfully."}};