refactor(vis): H4.5 step 2 — series endpoints on the canonical resolver

Series' visibleLibrarySet was the third hand-rolled set builder (with
its own FromBytes-error idiom, the fourth idiom in four copies).
SeriesService.VisibleLibraries — a pure pass-through to
GetUserVisibleLibraries — now has zero callers and dies with the
migration.
This commit is contained in:
John O'Keefe committed 2026-10-17 17:31:23 -04:00
1 parent 1d12a64915
commit d2d92efd10
1 file changed
+3 -18
+3 -18
View File
@@ -14,12 +14,14 @@ import (
type SeriesHandler struct { type SeriesHandler struct {
seriesService *services.SeriesService seriesService *services.SeriesService
libraryService *services.LibraryService
db *database.Queries db *database.Queries
} }
func NewSeriesHandler(db *database.Queries) *SeriesHandler { func NewSeriesHandler(db *database.Queries) *SeriesHandler {
return &SeriesHandler{ return &SeriesHandler{
seriesService: services.NewSeriesService(db), seriesService: services.NewSeriesService(db),
libraryService: services.NewLibraryService(db),
db: db, db: db,
} }
} }
@@ -104,24 +106,7 @@ func (h *SeriesHandler) visibleLibrarySet(c *echo.Context) (map[string]bool, []p
if !ok { if !ok {
return nil, nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user") return nil, nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user")
} }
libraries, err := h.seriesService.VisibleLibraries(c.Request().Context(), user.ID) return h.libraryService.VisibleLibrarySet(c.Request().Context(), user.ID)
if err != nil {
return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, "failed to check library access")
}
set := make(map[string]bool, len(libraries))
ids := make([]pgtype.UUID, 0, len(libraries))
for _, lib := range libraries {
if !lib.ID.Valid {
continue
}
libUUID, err := uuid.FromBytes(lib.ID.Bytes[0:16])
if err != nil {
continue
}
set[libUUID.String()] = true
ids = append(ids, lib.ID)
}
return set, ids, nil
} }
func (h *SeriesHandler) GetSeriesBooks(c *echo.Context) error { func (h *SeriesHandler) GetSeriesBooks(c *echo.Context) error {