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 ¶
- type Config
- type Directory
- type Outcome
- type PromptReader
- type Reach
- func (r *Reach) Access() *access.Checker
- func (r *Reach) CanOpen(ctx context.Context, email, targetType, targetID string) bool
- func (r *Reach) Decide(ctx context.Context, u *access.User, known bool, targetType, targetID string) Outcome
- func (r *Reach) Eligible(ctx context.Context, t mention.Target, emails []string) ([]string, error)
- func (r *Reach) Filter(ctx context.Context, targetType, targetID string, emails []string) []string
- func (r *Reach) Person(ctx context.Context, userID, email string) (u *access.User, persona string)
- func (r *Reach) PersonaName(roles []string) string
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 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 // BadTarget is a target type the decision does not know. BadTarget )
Outcomes of a decision.
type PromptReader ¶
PromptReader reads one prompt.
type Reach ¶
type Reach struct {
// contains filtered or unexported fields
}
Reach answers who can open a thread target.
func (*Reach) Access ¶ added in v1.166.4
Access is the authorization core the decisions are made with.
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 ¶
Eligible implements mention.Gate: a named address may be mentioned when its person can open the target.
func (*Reach) Person ¶ added in v1.166.4
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
PersonaName is the persona roles resolve to, "" with no resolver.