mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add reported-issues, Goodreads sync & notifs
Introduce user-reported-issues and Goodreads shelf sync features and wire them into notifications. Adds Prisma migrations and schema changes (ReportedIssue, GoodreadsShelf, GoodreadsBookMapping), API endpoints for reporting (POST /audiobooks/[asin]/report-issue) and admin management (list, resolve/dismiss, replace), and an admin UI section to view/dismiss/replace reported issues. Adds a new notification event (issue_reported) with updates to notification schemas, docs and provider handling, plus a notification-events constants file. Refactors request creation to use createRequestForUser service, adds a Goodreads sync processor/service/hooks/UI modals, a scrape-resilience util, and related tests and minor integration updates.
This commit is contained in:
+73
-1
@@ -64,6 +64,9 @@ model User {
|
||||
requests Request[]
|
||||
bookDateRecommendations BookDateRecommendation[]
|
||||
bookDateSwipes BookDateSwipe[]
|
||||
goodreadsShelves GoodreadsShelf[]
|
||||
reportedIssues ReportedIssue[] @relation("Reporter")
|
||||
resolvedIssues ReportedIssue[] @relation("Resolver")
|
||||
|
||||
@@index([plexId])
|
||||
@@index([role])
|
||||
@@ -197,7 +200,8 @@ model Audiobook {
|
||||
completedAt DateTime? @map("completed_at")
|
||||
|
||||
// Relations
|
||||
requests Request[]
|
||||
requests Request[]
|
||||
reportedIssues ReportedIssue[]
|
||||
|
||||
@@index([audibleAsin])
|
||||
@@index([plexGuid])
|
||||
@@ -456,3 +460,71 @@ model NotificationBackend {
|
||||
@@index([enabled])
|
||||
@@map("notification_backends")
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// REPORTED ISSUES TABLE
|
||||
// User-reported problems with available audiobooks (corrupted, wrong book, etc.)
|
||||
// ============================================================================
|
||||
|
||||
model ReportedIssue {
|
||||
id String @id @default(uuid())
|
||||
audiobookId String @map("audiobook_id")
|
||||
reporterId String @map("reporter_id")
|
||||
reason String @db.VarChar(250)
|
||||
status String @default("open") // open, dismissed, replaced
|
||||
resolvedAt DateTime? @map("resolved_at")
|
||||
resolvedById String? @map("resolved_by_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
// Relations
|
||||
audiobook Audiobook @relation(fields: [audiobookId], references: [id], onDelete: Cascade)
|
||||
reporter User @relation("Reporter", fields: [reporterId], references: [id], onDelete: Cascade)
|
||||
resolvedBy User? @relation("Resolver", fields: [resolvedById], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([audiobookId])
|
||||
@@index([reporterId])
|
||||
@@index([status])
|
||||
@@map("reported_issues")
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// GOODREADS SYNC TABLES
|
||||
// Per-user Goodreads shelf subscriptions + global book-to-ASIN mapping cache
|
||||
// ============================================================================
|
||||
|
||||
model GoodreadsShelf {
|
||||
id String @id @default(uuid())
|
||||
userId String @map("user_id")
|
||||
name String // Extracted from RSS <title>
|
||||
rssUrl String @map("rss_url") @db.Text
|
||||
lastSyncAt DateTime? @map("last_sync_at")
|
||||
bookCount Int? @map("book_count")
|
||||
coverUrls String? @map("cover_urls") @db.Text // JSON array of cover image URLs
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
// Relations
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([userId, rssUrl])
|
||||
@@index([userId])
|
||||
@@map("goodreads_shelves")
|
||||
}
|
||||
|
||||
model GoodreadsBookMapping {
|
||||
id String @id @default(uuid())
|
||||
goodreadsBookId String @unique @map("goodreads_book_id")
|
||||
title String
|
||||
author String
|
||||
audibleAsin String? @map("audible_asin")
|
||||
coverUrl String? @map("cover_url") @db.Text
|
||||
noMatch Boolean @default(false) @map("no_match")
|
||||
lastSearchAt DateTime? @map("last_search_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@index([goodreadsBookId])
|
||||
@@index([audibleAsin])
|
||||
@@map("goodreads_book_mappings")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user