removed AircraftID, Added NExtcloud permission
This commit is contained in:
@@ -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
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user