reachapi

package
v1.166.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package reachapi serves the portal's search and facets over a person's reach (#2500): GET /api/v1/portal/assets/search, /assets/facets, /collections/search and /collections/facets, and the per-row description (share summaries, permissions) the portal's listings attach to a page.

Every route asks the store for what the caller can open, narrowed to the scope the request names; the store applies the reach in SQL (internal/portal/reachstore), so a row the caller cannot open is never returned, ranked or counted. It is built only by pkg/portal, which mounts it and calls its row description from the listing routes it still owns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marks added in v1.166.0

func Marks(r *http.Request) (status string, verified bool)

Marks is the status and verified filters (#2502, #2503): status is draft, published, deprecated or none (an unknown value filters nothing), and verified=true keeps only assets carrying an unexpired verification.

func OwnedCollectionIDs

func OwnedCollectionIDs(collections []portaldomain.Collection, user *access.User) []string

OwnedCollectionIDs is the ids of the collections the caller owns, the rows whose share summaries are theirs to see.

func Owners

func Owners(r *http.Request) []string

Owners is the author filter: owner addresses, repeated or comma-separated.

func Reach

func Reach(r *http.Request, user *access.User, fallback portaldomain.Scope) *portaldomain.Reach

Reach is the caller's reach for a listing or search: everything they can open, narrowed to the scope the request names (fallback when it names none). An administrator's reach is their own; the admin listing is the route that spans every owner.

Types

type Config

type Config struct {
	Assets      any
	Collections any
	Shares      portaldomain.ShareStore
	Access      *access.Checker
	// Embed turns a query into a vector, nil when no provider is
	// configured, which ranks lexically.
	Embed func(ctx context.Context, query string) []float32
}

Config is what the routes read: the stores (each used for the capabilities it implements), the authorization core and the query embedder.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves the reach routes.

func New

func New(cfg Config) *Handler

New builds the reach routes.

func (*Handler) CollectionPermissions

func (h *Handler) CollectionPermissions(ctx context.Context, collections []portaldomain.Collection, user *access.User) map[string]portaldomain.SharePermission

CollectionPermissions is the caller's share permission on each listed collection they do not own.

func (*Handler) DescribeAssets

func (h *Handler) DescribeAssets(ctx context.Context, assets []portaldomain.Asset, reach *portaldomain.Reach, user *access.User) Rows

DescribeAssets describes a page of assets for the caller.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts the routes the configured stores support.

type Rows

type Rows struct {
	Summaries   map[string]portaldomain.ShareSummary
	Permissions map[string]portaldomain.SharePermission
}

Rows is what a page of assets reports beside its rows: the share summaries of the rows the caller owns, and the caller's permission on each row they do not. A share summary says whether a row has a public link, which is its owner's to know, so a row shared with the caller carries none.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL