mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40:09 +00:00
cbf02d3e24
Introduce watched lists for series and authors end-to-end. - Add DB migration to create watched_series and watched_authors tables with indexes and foreign keys. - Implement API routes: GET/POST for listing/adding and DELETE by id for both /api/user/watched-series and /api/user/watched-authors. Validation, ownership checks, and immediate targeted job triggers are included. - Add client hooks (useWatchedSeries, useWatchedAuthors) with add/delete helpers and SWR revalidation. - Add UI components: WatchButton (toggle/confirm) and WatchedListsSection for profile display and removal UX. - Add processor (check-watched-lists.processor) and service (watched-lists.service) to scrape Audible, deduplicate, check library ownership, and auto-create requests; supports targeted checks for newly watched items. - Include tests for the watched-lists service. These changes implement the watched-lists feature to let users watch series/authors and have the system automatically detect and request new releases.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/**
|
|
* Component: Check Watched Lists Processor
|
|
* Documentation: documentation/features/watched-lists.md
|
|
*
|
|
* Dedicated processor for checking watched series and watched authors
|
|
* for new releases and auto-creating requests.
|
|
* Supports targeted processing of a single series/author for immediate sync.
|
|
*/
|
|
|
|
import { RMABLogger } from '../utils/logger';
|
|
|
|
export interface CheckWatchedListsPayload {
|
|
jobId?: string;
|
|
scheduledJobId?: string;
|
|
/** If set, only process watched items for this user */
|
|
userId?: string;
|
|
/** If set, only process this specific series */
|
|
seriesAsin?: string;
|
|
/** If set, only process this specific author */
|
|
authorAsin?: string;
|
|
}
|
|
|
|
export async function processCheckWatchedLists(payload: CheckWatchedListsPayload): Promise<any> {
|
|
const { jobId, userId, seriesAsin, authorAsin } = payload;
|
|
const logger = RMABLogger.forJob(jobId, 'CheckWatchedLists');
|
|
|
|
const isTargeted = !!(userId && (seriesAsin || authorAsin));
|
|
logger.info(isTargeted
|
|
? `Starting targeted watched lists check (user: ${userId}, series: ${seriesAsin || 'n/a'}, author: ${authorAsin || 'n/a'})...`
|
|
: 'Starting watched lists check...'
|
|
);
|
|
|
|
const { processWatchedLists } = await import('../services/watched-lists.service');
|
|
const stats = await processWatchedLists(logger, { userId, seriesAsin, authorAsin });
|
|
|
|
logger.info('Watched lists check complete', { stats });
|
|
|
|
return {
|
|
success: true,
|
|
message: isTargeted ? 'Targeted watched item checked' : 'Watched lists checked',
|
|
...stats,
|
|
};
|
|
}
|