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