mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 12:50:09 +00:00
Implement user soft-delete and improve search ranking
Adds soft-delete support for local users, including backend, API, and UI changes to allow admins to delete local users while preserving their requests. Updates user queries to exclude deleted users and allows username reuse for deleted accounts. Refines search and ranking logic for torrents: uses title-only queries for broader results, increases max results to 100, applies a minimum score threshold (30/100), and logs detailed ranking breakdowns. Updates the ranking algorithm to prioritize title/author match, adjusts scoring weights, and improves BookDate compatibility with Audiobookshelf by disabling rating-based features when unsupported. Enhances file copy operations for large files, improves metadata tagging, and updates documentation to reflect new search and ranking strategies.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { requireAuth, AuthenticatedRequest } from '@/lib/middleware/auth';
|
||||
import { prisma } from '@/lib/db';
|
||||
import { getConfigService } from '@/lib/services/config.service';
|
||||
|
||||
/**
|
||||
* GET /api/bookdate/preferences
|
||||
@@ -32,10 +33,24 @@ async function getPreferences(req: AuthenticatedRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// Add backend capability detection
|
||||
const configService = getConfigService();
|
||||
const backendMode = await configService.getBackendMode();
|
||||
const supportsRatings = backendMode === 'plex';
|
||||
|
||||
// Override 'rated' scope if backend doesn't support it
|
||||
let effectiveScope = user.bookDateLibraryScope || 'full';
|
||||
if (!supportsRatings && effectiveScope === 'rated') {
|
||||
effectiveScope = 'full';
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
libraryScope: user.bookDateLibraryScope || 'full',
|
||||
libraryScope: effectiveScope,
|
||||
customPrompt: user.bookDateCustomPrompt || '', // Always return empty string for UI
|
||||
onboardingComplete: user.bookDateOnboardingComplete || false,
|
||||
backendCapabilities: {
|
||||
supportsRatings,
|
||||
},
|
||||
});
|
||||
|
||||
} catch (error: any) {
|
||||
@@ -67,6 +82,18 @@ async function updatePreferences(req: AuthenticatedRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// Add validation for rating support
|
||||
const configService = getConfigService();
|
||||
const backendMode = await configService.getBackendMode();
|
||||
const supportsRatings = backendMode === 'plex';
|
||||
|
||||
if (libraryScope === 'rated' && !supportsRatings) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Your backend does not support ratings. Please select "Full Library".' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Validate custom prompt length (only if provided and not empty)
|
||||
if (customPrompt && typeof customPrompt === 'string' && customPrompt.trim() && customPrompt.length > 1000) {
|
||||
return NextResponse.json(
|
||||
|
||||
Reference in New Issue
Block a user