Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
- Introduce provider abstraction layer (IMediaProvider, KomgaProvider, StripstreamProvider) - Add Stripstream Librarian as second media provider with full feature parity - Migrate all pages and components from direct Komga services to provider factory - Remove dead service code (BaseApiService, HomeService, LibraryService, SearchService, TestService) - Fix library/series page-based pagination for both providers (Komga 0-indexed, Stripstream 1-indexed) - Fix unread filter and search on library page for both providers - Fix read progress display for Stripstream (reading_status mapping) - Fix series read status (books_read_count) for Stripstream - Add global search with series results for Stripstream (series_hits from Meilisearch) - Fix thumbnail proxy to return 404 gracefully instead of JSON on upstream error - Replace duration-based cache debug detection with x-nextjs-cache header Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import { getProvider } from "@/lib/providers/provider.factory";
|
|
import { AppError } from "@/utils/errors";
|
|
|
|
export async function scanLibrary(
|
|
libraryId: string
|
|
): Promise<{ success: boolean; message: string }> {
|
|
try {
|
|
const provider = await getProvider();
|
|
if (!provider) return { success: false, message: "Provider non configuré" };
|
|
|
|
await provider.scanLibrary(libraryId);
|
|
|
|
revalidatePath(`/libraries/${libraryId}`);
|
|
revalidatePath("/libraries");
|
|
|
|
return { success: true, message: "Scan lancé" };
|
|
} catch (error) {
|
|
if (error instanceof AppError) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
return { success: false, message: "Erreur lors du scan" };
|
|
}
|
|
}
|
|
|
|
export async function getRandomBookFromLibraries(
|
|
libraryIds: string[]
|
|
): Promise<{ success: boolean; bookId?: string; message?: string }> {
|
|
try {
|
|
if (!libraryIds.length) {
|
|
return { success: false, message: "Au moins une bibliothèque doit être sélectionnée" };
|
|
}
|
|
|
|
const provider = await getProvider();
|
|
if (!provider) return { success: false, message: "Provider non configuré" };
|
|
|
|
const bookId = await provider.getRandomBook(libraryIds);
|
|
return { success: true, bookId: bookId ?? undefined };
|
|
} catch (error) {
|
|
if (error instanceof AppError) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
return { success: false, message: "Erreur lors de la récupération d'un livre aléatoire" };
|
|
}
|
|
}
|