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:
1 parent
1d12a64915
commit
d2d92efd10
1 file changed
+7
-22
@@ -13,14 +13,16 @@ import (
|
||||
)
|
||||
|
||||
type SeriesHandler struct {
|
||||
seriesService *services.SeriesService
|
||||
db *database.Queries
|
||||
seriesService *services.SeriesService
|
||||
libraryService *services.LibraryService
|
||||
db *database.Queries
|
||||
}
|
||||
|
||||
func NewSeriesHandler(db *database.Queries) *SeriesHandler {
|
||||
return &SeriesHandler{
|
||||
seriesService: services.NewSeriesService(db),
|
||||
db: db,
|
||||
seriesService: services.NewSeriesService(db),
|
||||
libraryService: services.NewLibraryService(db),
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,24 +106,7 @@ func (h *SeriesHandler) visibleLibrarySet(c *echo.Context) (map[string]bool, []p
|
||||
if !ok {
|
||||
return nil, nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user")
|
||||
}
|
||||
libraries, err := h.seriesService.VisibleLibraries(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
|
||||
return h.libraryService.VisibleLibrarySet(c.Request().Context(), user.ID)
|
||||
}
|
||||
|
||||
func (h *SeriesHandler) GetSeriesBooks(c *echo.Context) error {
|
||||
|
||||
Reference in new issue
Block a user