threadreach

package
v1.167.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package threadreach decides who can open a feedback thread's target (#2512): the caller of a thread route, and a person a message names or a thread involves. Both questions are answered by the one decision here, made with the portal's authorization core (internal/portal/access), so the people a mention reaches and a reply notifies are exactly the people the target's read admits -- by ownership, an email share, a persona share, a collection share or administration -- and not a second, hand-kept list.

A person named by address is judged as they would be if they signed in now: the roles the known-users directory last recorded for them decide their persona and whether they administer the platform. An address the directory does not hold is judged with no roles, so only a grant addressed to that address admits it; a target open to every signed-in person (a knowledge page, the general channel, a prompt that is not personal) admits only the people the directory holds, so a message can never mail an arbitrary address.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Access         *access.Checker
	Assets         portaldomain.AssetStore
	Collections    portaldomain.CollectionStore
	Prompts        PromptReader
	KnowledgePages knowledgepage.Store
	// Directory holds the roles a named person last signed in with. nil
	// judges every named person with no roles.
	Directory Directory
	// PersonaName resolves roles to the persona a share may be addressed
	// to (#2089). nil resolves none.
	PersonaName func(roles []string) string
}

Config is what a decision reads.

type Directory

type Directory interface {
	Get(ctx context.Context, email string) (*user.User, error)
}

Directory is the known-users directory a named person's roles are read from.

type Outcome

type Outcome int

Outcome is what a decision found.

const (
	// Open admits the person.
	Open Outcome = iota
	// Missing is a target that does not exist or was deleted.
	Missing
	// Denied is a target the person may not open.
	Denied
	// Failed is a check that could not complete.
	Failed
	// Unavailable is a target kind this deployment has no store for.
	Unavailable
	// BadTarget is a target type the decision does not know.
	BadTarget
)

Outcomes of a decision.

type PromptReader

type PromptReader interface {
	GetByID(ctx context.Context, id string) (*prompt.Prompt, error)
}

PromptReader reads one prompt.

type Reach

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

Reach answers who can open a thread target.

func New

func New(cfg Config) *Reach

New returns a Reach over cfg.

func (*Reach) Access added in v1.166.4

func (r *Reach) Access() *access.Checker

Access is the authorization core the decisions are made with.

func (*Reach) CanOpen

func (r *Reach) CanOpen(ctx context.Context, email, targetType, targetID string) bool

CanOpen reports whether the person at an address can open the target now.

func (*Reach) Decide

func (r *Reach) Decide(ctx context.Context, u *access.User, known bool, targetType, targetID string) Outcome

Decide reports whether u may open the target. The caller's persona is the one on ctx (portaldomain.WithCallerPersona), as on every portal request. known says whether the person is one the platform knows: a signed-in caller always is; a named address only when the directory holds it.

func (*Reach) Eligible

func (r *Reach) Eligible(ctx context.Context, t mention.Target, emails []string) ([]string, error)

Eligible implements mention.Gate: a named address may be mentioned when its person can open the target.

func (*Reach) Filter

func (r *Reach) Filter(ctx context.Context, targetType, targetID string, emails []string) []string

Filter returns the addresses that can open the target, in their order.

func (*Reach) Person added in v1.166.4

func (r *Reach) Person(ctx context.Context, userID, email string) (u *access.User, persona string)

Person is the principal a record's owner is judged as -- the owner id and address it records, with the roles the directory last recorded for the address, none when it holds no record -- and the persona those roles resolve to. The collection item sweep (#2752) judges a collection's owner by it, as a mention judges a named person.

func (*Reach) PersonaName added in v1.166.4

func (r *Reach) PersonaName(roles []string) string

PersonaName is the persona roles resolve to, "" with no resolver.

Jump to

Keyboard shortcuts

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