refactor(vis): H4.5 step 3 — collections endpoint and the SSR helper on the canonical resolver
collections.userVisibleLibraryIDs keeps its identity adapter and delegates; the router's visibleLibraryIDsFor likewise (its identity source is the session user_id string, the site-specific part it keeps). The SSR site made the unification slog-proof: resolveLibrary — the SSR one-of-a-kind (active selection + switcher rows + offline detection) — stays untouched per the semantic diff.
This commit is contained in:
1 parent
d2d92efd10
commit
8dbaa8f810
2 files changed
+5
-25
No files matched your search
@@ -741,22 +741,15 @@ func (h *CollectionHandler) GetUserCollectionsList(c *echo.Context) ([]database.
|
||||
// userVisibleLibraryIDs loads the requester's visible-library set (the
|
||||
// family lens). Smart-collection evaluation funnels every book candidate
|
||||
// through it so hidden libraries contribute nothing.
|
||||
// userVisibleLibraryIDs adapts the collection endpoints' identity
|
||||
// source to the canonical resolver (H4.5).
|
||||
func (h *CollectionHandler) userVisibleLibraryIDs(c *echo.Context) ([]pgtype.UUID, error) {
|
||||
user, ok := c.Get("user").(database.Users)
|
||||
if !ok {
|
||||
return nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user")
|
||||
}
|
||||
rows, err := h.libraryService.GetUserVisibleLibraries(c.Request().Context(), user.ID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to check library access: %w", err)
|
||||
}
|
||||
ids := make([]pgtype.UUID, 0, len(rows))
|
||||
for _, lib := range rows {
|
||||
if lib.ID.Valid {
|
||||
ids = append(ids, lib.ID)
|
||||
}
|
||||
}
|
||||
return ids, nil
|
||||
_, ids, err := h.libraryService.VisibleLibrarySet(c.Request().Context(), user.ID)
|
||||
return ids, err
|
||||
}
|
||||
|
||||
// UserVisibleLibraryIDs is the exported entry point for the router's
|
||||
|
||||
@@ -255,18 +255,5 @@ func visibleLibraryIDsFor(c *echo.Context, cfg *Config) (map[string]bool, []pgty
|
||||
if err != nil {
|
||||
return nil, nil, echo.NewHTTPError(http.StatusUnauthorized, "invalid user")
|
||||
}
|
||||
libraries, err := cfg.Queries.GetUserVisibleLibraries(c.Request().Context(), uuidToPGType(userU))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
set := make(map[string]bool, len(libraries))
|
||||
ids := make([]pgtype.UUID, 0, len(libraries))
|
||||
for _, lib := range libraries {
|
||||
if !lib.ID.Valid {
|
||||
continue
|
||||
}
|
||||
set[lib.ID.String()] = true
|
||||
ids = append(ids, lib.ID)
|
||||
}
|
||||
return set, ids, nil
|
||||
return cfg.LibraryService.VisibleLibrarySet(c.Request().Context(), uuidToPGType(userU))
|
||||
}
|
||||
Reference in new issue
Block a user