refactor(handlers): consume port interfaces, wire media+upload assembly (Task 25+26)
- H now holds only small port interfaces (UserStore/LibraryStore/BookStore/ ProgressStore/BookmarkStore/RateLimiter/Scanner/Media/UploadSessions); NewRouter is the composition root distributing *store.Store and *redispkg.R - ports.Media gains EnsurePage; ChaptersOf returns ports.Chapter (media's local duplicate dropped); *media.M now provably satisfies ports.Media; ports.UploadSessions gains LibraryID for root validation before Complete - content.go: duplicated page-index cache + cover self-heal + page extract logic removed in favor of media service — same redis keys, same contract; path traversal check stays in handler (403 semantics preserved) - getLibrary/getLibRow merged into getLib(c, id); idParam helper dedupes :id parsing; isUnique replaced by ports.IsUniqueViolation (Task 28 partial) - main.go assembles media + upload and passes upload.U as scanner Sweeper Full gate green: gofmt, vet, go test -p 1 (real PG+Redis, 0 skip)
This commit is contained in:
@@ -27,7 +27,7 @@ func (h *H) ListBookmarks(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
rows, e := h.st.ListBookmarks(c, uid(c), b.LibraryID, b.Path)
|
||||
rows, e := h.bookmarks.ListBookmarks(c, uid(c), b.LibraryID, b.Path)
|
||||
if e != nil {
|
||||
dbErr(c, e)
|
||||
return
|
||||
@@ -65,7 +65,7 @@ func (h *H) CreateBookmark(c *gin.Context) {
|
||||
err(c, http.StatusBadRequest, "bad_request", "note too long (max 500 characters)")
|
||||
return
|
||||
}
|
||||
id, e := h.st.InsertBookmark(c, uid(c), b.LibraryID, b.Path, req.Locator, req.Percent, req.Note)
|
||||
id, e := h.bookmarks.InsertBookmark(c, uid(c), b.LibraryID, b.Path, req.Locator, req.Percent, req.Note)
|
||||
if e != nil {
|
||||
dbErr(c, e)
|
||||
return
|
||||
@@ -101,7 +101,7 @@ func (h *H) PatchBookmark(c *gin.Context) {
|
||||
err(c, http.StatusBadRequest, "bad_request", "note too long (max 500 characters)")
|
||||
return
|
||||
}
|
||||
updated, e := h.st.UpdateBookmarkNote(c, uid(c), id, req.Note)
|
||||
updated, e := h.bookmarks.UpdateBookmarkNote(c, uid(c), id, req.Note)
|
||||
if e != nil {
|
||||
dbErr(c, e)
|
||||
return
|
||||
@@ -118,7 +118,7 @@ func (h *H) DeleteBookmark(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
deleted, e := h.st.DeleteBookmark(c, uid(c), id)
|
||||
deleted, e := h.bookmarks.DeleteBookmark(c, uid(c), id)
|
||||
if e != nil {
|
||||
dbErr(c, e)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user