1 line
3.3 KiB
JavaScript
1 line
3.3 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:()=>l,workUnitAsyncStorage:()=>q});var s={};t.r(s),t.d(s,{DELETE:()=>x});var i=t(96559),o=t(48088),a=t(37719),n=t(32190),u=t(19854),p=t(26690),d=t(79464),c=t(22039);async function m(e){let r=await (0,u.getServerSession)(p.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 x(e,r){let t=await r.params;try{let{authorized:r,userId:s}=await m(e);if(!r||!s)return n.NextResponse.json({error:"Unauthorized"},{status:401});let{missionId:i,attachmentId:o}=t;if(!i||!o)return n.NextResponse.json({error:"Mission ID and Attachment ID are required"},{status:400});if(!await d.z.mission.findFirst({where:{id:i,OR:[{creatorId:s},{missionUsers:{some:{userId:s,role:"gardien-memoire"}}}]}}))return n.NextResponse.json({error:"Mission not found or access denied"},{status:404});let a=await d.z.attachment.findUnique({where:{id:o,missionId:i}});if(!a)return n.NextResponse.json({error:"Attachment not found"},{status:404});return await (0,c.zt)(a.filePath),await d.z.attachment.delete({where:{id:o}}),n.NextResponse.json({success:!0})}catch(e){return console.error("Error deleting attachment:",e),n.NextResponse.json({error:"Internal server error",details:e instanceof Error?e.message:String(e)},{status:500})}}let h=new i.AppRouteRouteModule({definition:{kind:o.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:l,workUnitAsyncStorage:q,serverHooks:f}=h;function w(){return(0,a.patchFetch)({workAsyncStorage:l,workUnitAsyncStorage:q})}},21820:e=>{e.exports=require("os")},27910:e=>{e.exports=require("stream")},28354:e=>{e.exports=require("util")},29021:e=>{e.exports=require("fs")},29294:e=>{e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:e=>{e.exports=require("path")},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")},57075:e=>{e.exports=require("node:stream")},63033:e=>{e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},73496:e=>{e.exports=require("http2")},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,1046,6300],()=>t(13298));module.exports=s})(); |