1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
"use strict";(()=>{var e={};e.id=6895,e.ids=[6895],e.modules={3295:e=>{e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},11723:e=>{e.exports=require("querystring")},12412:e=>{e.exports=require("assert")},13298:(e,r,t)=>{t.r(r),t.d(r,{patchFetch:()=>w,routeModule:()=>h,serverHooks:()=>f,workAsyncStorage:()=>x,workUnitAsyncStorage:()=>q});var s={};t.r(s),t.d(s,{DELETE:()=>l});var n=t(96559),a=t(48088),i=t(37719),o=t(32190),u=t(19854),d=t(26690),p=t(79464),c=t(22039);async function m(e){let r=await (0,u.getServerSession)(d.N);return r?.user?.id?{authorized:!0,userId:r.user.id}:(console.error("Unauthorized access attempt:",{url:e.url,method:e.method,headers:Object.fromEntries(e.headers)}),{authorized:!1,userId:null})}async function l(e,r){let t=await r.params;try{let{authorized:r,userId:s}=await m(e);if(!r||!s)return o.NextResponse.json({error:"Unauthorized"},{status:401});let{missionId:n,attachmentId:a}=t;if(!n||!a)return o.NextResponse.json({error:"Mission ID and Attachment ID are required"},{status:400});if(!await p.z.mission.findFirst({where:{id:n,OR:[{creatorId:s},{missionUsers:{some:{userId:s,role:"gardien-memoire"}}}]}}))return o.NextResponse.json({error:"Mission not found or access denied"},{status:404});let i=await p.z.attachment.findUnique({where:{id:a,missionId:n}});if(!i)return o.NextResponse.json({error:"Attachment not found"},{status:404});return await (0,c.zt)(i.filePath),await p.z.attachment.delete({where:{id:a}}),o.NextResponse.json({success:!0})}catch(e){return console.error("Error deleting attachment:",e),o.NextResponse.json({error:"Internal server error",details:e instanceof Error?e.message:String(e)},{status:500})}}let h=new n.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/missions/[missionId]/attachments/[attachmentId]/route",pathname:"/api/missions/[missionId]/attachments/[attachmentId]",filename:"route",bundlePath:"app/api/missions/[missionId]/attachments/[attachmentId]/route"},resolvedPagePath:"/Users/alma/Documents/NeahNew/app/api/missions/[missionId]/attachments/[attachmentId]/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:x,workUnitAsyncStorage:q,serverHooks:f}=h;function w(){return(0,i.patchFetch)({workAsyncStorage:x,workUnitAsyncStorage:q})}},28354:e=>{e.exports=require("util")},29294:e=>{e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{e.exports=require("crypto")},55591:e=>{e.exports=require("https")},63033:e=>{e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},74075:e=>{e.exports=require("zlib")},79428:e=>{e.exports=require("buffer")},79551:e=>{e.exports=require("url")},81630:e=>{e.exports=require("http")},91043:e=>{e.exports=require("@aws-sdk/client-s3")},94735:e=>{e.exports=require("events")},96330:e=>{e.exports=require("@prisma/client")}};var r=require("../../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[4243,5419,580,762,6300],()=>t(13298));module.exports=s})(); |