removed AircraftID, Added NExtcloud permission

This commit is contained in:
PxlLoewe
2025-06-30 13:37:42 -07:00
parent b940b70839
commit 536d214840
15 changed files with 58 additions and 39 deletions

View File

@@ -5,18 +5,12 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
try {
const connectedAircraftId = request.nextUrl.searchParams.get("connectedAircraftId");
const aircraft = await prisma.connectedAircraft.findUnique({
where: {
id: connectedAircraftId ? parseInt(connectedAircraftId) : undefined,
},
});
if (!aircraft) return NextResponse.json({ error: "Aircraft not found" }, { status: 404 });
if (!connectedAircraftId)
return NextResponse.json({ error: "connectedAircraftId is required" }, { status: 400 });
const positionLog = await prisma.positionLog.findMany({
where: {
id: {
in: aircraft.positionLogIds,
},
connectedAircraftId: Number(connectedAircraftId),
timestamp: {
gte: new Date(Date.now() - 2 * 60 * 60 * 1000), // Last 2 hours
},

View File

@@ -44,9 +44,11 @@ export const PUT = async (req: Request) => {
if (!activeAircraft) {
return Response.json({ message: "No active aircraft found" }, { status: 400 });
}
const positionLog = await prisma.positionLog.create({
data: {
...position,
connectedAircraftId: activeAircraft.id,
userId,
},
});
@@ -64,9 +66,6 @@ export const PUT = async (req: Request) => {
posHeading: positionLog.heading,
posSpeed: positionLog.speed,
posH145active: h145,
positionLogIds: {
push: positionLog.id,
},
},
});