Bug #1 — Memory Echo cassé (runtime crash): - lib/ai/services/memory-echo.service.ts: lignes adjustedThreshold restaurées - Cause: sed console.log avait supprimé les lignes de définition - Effet: findConnections() crashait (ReferenceError) Bug #2 — Auth mobile totalement cassée (sécurité): - 14 routes app/api/mobile/*/: getMobileUserId(req) → await getMobileUserId(req) - Cause: verifyMobileToken devenu async mais callers non mis à jour - Effet: auth bypassée (Promise truthy au lieu de string) i18n: - searchModal.* + insightsView.* propagés dans 13 locales (EN fallback)
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import prisma from '@/lib/prisma'
|
|
import { getMobileUserId } from '@/lib/mobile-auth'
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const userId = await getMobileUserId(req)
|
|
if (!userId) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
|
|
const now = new Date()
|
|
const decks = await prisma.flashcardDeck.findMany({
|
|
where: { userId },
|
|
include: {
|
|
notebook: { select: { name: true } },
|
|
flashcards: {
|
|
select: {
|
|
id: true,
|
|
interval: true,
|
|
nextReviewAt: true,
|
|
front: true,
|
|
},
|
|
},
|
|
},
|
|
orderBy: { updatedAt: 'desc' },
|
|
})
|
|
|
|
const result = decks.map((deck) => ({
|
|
id: deck.id,
|
|
name: deck.name,
|
|
notebookId: deck.notebookId,
|
|
notebookName: deck.notebook?.name ?? null,
|
|
totalCards: deck.flashcards.length,
|
|
dueCount: deck.flashcards.filter((c) => c.nextReviewAt <= now).length,
|
|
masteredCount: deck.flashcards.filter((c) => c.interval >= 7).length,
|
|
}))
|
|
|
|
return NextResponse.json({ decks: result })
|
|
}
|