mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
Add multi-source ebook support and per-indexer categories
Introduces granular toggles for Anna's Archive and Indexer Search as ebook sources, updates settings UI to a three-section layout, and documents the new configuration. Adds per-indexer category configuration with separate tabs for audiobooks and ebooks, updates API routes and types for new settings, and ensures legacy config migration. Indexer grouping and file organization logic now support the new category structure and ebook source toggles.
This commit is contained in:
@@ -22,14 +22,30 @@ export async function POST(
|
||||
try {
|
||||
const { id: parentRequestId } = await params;
|
||||
|
||||
// Check if e-book sidecar is enabled
|
||||
const ebookEnabledConfig = await prisma.configuration.findUnique({
|
||||
where: { key: 'ebook_sidecar_enabled' },
|
||||
});
|
||||
// Check which ebook sources are enabled
|
||||
const [annasArchiveConfig, indexerSearchConfig, legacyConfig] = await Promise.all([
|
||||
prisma.configuration.findUnique({ where: { key: 'ebook_annas_archive_enabled' } }),
|
||||
prisma.configuration.findUnique({ where: { key: 'ebook_indexer_search_enabled' } }),
|
||||
prisma.configuration.findUnique({ where: { key: 'ebook_sidecar_enabled' } }),
|
||||
]);
|
||||
|
||||
if (ebookEnabledConfig?.value !== 'true') {
|
||||
// Legacy migration: check old key if new keys don't exist
|
||||
const isAnnasArchiveEnabled = annasArchiveConfig?.value === 'true' ||
|
||||
(annasArchiveConfig === null && legacyConfig?.value === 'true');
|
||||
const isIndexerSearchEnabled = indexerSearchConfig?.value === 'true';
|
||||
|
||||
// If no sources are enabled, return error
|
||||
if (!isAnnasArchiveEnabled && !isIndexerSearchEnabled) {
|
||||
return NextResponse.json(
|
||||
{ error: 'E-book sidecar feature is not enabled' },
|
||||
{ error: 'E-book sidecar feature is not enabled (no sources configured)' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// If only indexer search is enabled (not yet implemented), return error
|
||||
if (!isAnnasArchiveEnabled && isIndexerSearchEnabled) {
|
||||
return NextResponse.json(
|
||||
{ error: 'E-book indexer search is not yet implemented. Enable Anna\'s Archive to fetch e-books.' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user