Add watched series/authors feature

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.
This commit is contained in:
kikootwo
2026-03-03 21:57:38 -05:00
parent 610873af6b
commit cbf02d3e24
23 changed files with 2392 additions and 32 deletions
@@ -0,0 +1,43 @@
/**
* 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,
};
}