Add backend support for users to follow series

Introduces a UserSeriesFollow model with a dedicated join table so users
can follow/unfollow series and receive socket notifications when new
books are added to followed series. The user JSON response now includes a
seriesFollowing array, and three new API endpoints are available under
/api/me/follows/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul DeVito 2026-03-22 20:29:11 -04:00
parent 8b89b27654
commit 37b95582a2
9 changed files with 744 additions and 5 deletions

View file

@ -13,6 +13,7 @@ const TaskManager = require('../managers/TaskManager')
const LibraryItemScanner = require('./LibraryItemScanner')
const LibraryScan = require('./LibraryScan')
const LibraryItemScanData = require('./LibraryItemScanData')
const { notifyFollowersOfNewBook } = require('../utils/followNotifications')
const Task = require('../objects/Task')
class LibraryScanner {
@ -263,6 +264,7 @@ class LibraryScanner {
const newLibraryItem = await LibraryItemScanner.scanNewLibraryItem(libraryItemData, libraryScan.library.settings, libraryScan)
if (newLibraryItem) {
newLibraryItems.push(newLibraryItem)
notifyFollowersOfNewBook(newLibraryItem)
libraryScan.resultsAdded++
}
@ -633,6 +635,7 @@ class LibraryScanner {
const newLibraryItem = await LibraryItemScanner.scanPotentialNewLibraryItem(fullPath, library, folder, isSingleMediaItem)
if (newLibraryItem) {
SocketAuthority.libraryItemEmitter('item_added', newLibraryItem)
notifyFollowersOfNewBook(newLibraryItem)
}
itemGroupingResults[itemDir] = newLibraryItem ? ScanResult.ADDED : ScanResult.NOTHING
}