legal

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 25 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 legal is the legal texts api serves (R52; R130, R136 spec): the part legal/ of spec at the tag api pins, spec.Legal, or a self-hosted copy's folder of its operator's texts, read once at the start by the rules of legal/README.md, section 5. It answers LegalService.GetLegalTexts, and tells whether a request that gives a consent names the current versions of the texts it is given to.

Index

Constants

View Source
const (
	PrivacyPolicy  = "privacy-policy"
	TermsOfUse     = "terms-of-use"
	ParentConsent  = "parent-consent"
	TeenConsent    = "teen-consent"
	StorageConsent = "storage-consent"
)

The texts the requests of a consent name (contracts README, section 15).

View Source
const (
	StepSchema           = "schema"
	RuleFiles            = "legal.files"
	RuleVersions         = "legal.versions"
	RuleSetTexts         = "legal.set-texts"
	RuleMarkdown         = "legal.markdown"
	RuleInForceUnchanged = "legal.in-force-unchanged"
)

The steps of reading a part, by the names section 5 of legal/README.md gives them: the schema, then the rules in their order.

Variables

This section is empty.

Functions

func Markdown

func Markdown(source []byte) bool

Markdown says whether source keeps legal.markdown: it begins with a heading of the first level, and holds no HTML, no image and no link — an autolink, a literal one of GFM and a definition of a link among them.

func Read

func Read(part Part, previous *Part) (legalv2.Legal, error)

Read reads the part by section 5: the schema of the passport, then legal.files, legal.versions, legal.set-texts and legal.markdown, then, when previous is the part of the release before, legal.in-force-unchanged. It gives the passport, or the Refusal of the first step that refuses the part: a part is never read in part.

Types

type Part

type Part struct {
	Passport json.RawMessage
	Files    map[string][]byte
}

Part is a part of the legal texts as it is read: its passport as a JSON value and its files under texts/, by their paths from the part.

type Refusal

type Refusal struct {
	Step  string
	Names []string
}

Refusal is a part that a step of section 5 refuses, with the names it gives: the paths the schema refuses, or what a rule names, in the order of code units.

func (*Refusal) Error

func (r *Refusal) Error() string

type Service

type Service struct {
	apiv1connect.UnimplementedLegalServiceHandler
	// contains filtered or unexported fields
}

Service is LegalService on the texts.

func NewService

func NewService(texts *Texts) *Service

NewService is LegalService on texts.

func (*Service) GetLegalTexts

func (s *Service) GetLegalTexts(ctx context.Context, req *v1.GetLegalTextsRequest) (*v1.GetLegalTextsResponse, error)

GetLegalTexts gives the current version of every text whose place is app, by ID in the order of code units: its body, its summary in the language asked — or else in English — and its translation into it, when the version has one, with no English in its place (contracts README, section 15). The answer is kept for an hour. A tag that is no BCP 47 is the one refusal.

type Text

type Text struct {
	ID           string
	Version      int32
	InForceSince string
	Place        string
	Body         string
	// Summaries is the gist of the version, by the tag of its language.
	Summaries map[string]string
	// Translations is the translations of the version, by the tag of their
	// language, other than English.
	Translations map[string]string
}

Text is the current version of a text.

type Texts

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

Texts is the current version of every text of a part that has one.

func Load

func Load() (*Texts, error)

Load is the texts of spec's Go module at the tag api pins, read as section 5 reads a part: spec checked them before its release, and the same rules hold them here, but legal.in-force-unchanged, which needs the release before.

func LoadDir

func LoadDir(dir string) (*Texts, error)

LoadDir is the texts of a self-hosted copy's folder at dir, which holds VERSION, legal.yaml and texts/ alone, its VERSION that of the part of spec's tag, and keeps the rules of section 5 but legal.in-force-unchanged: the copy's operator keeps its own history (legal/README.md, section 8).

func Spec

func Spec() *Texts

Spec is the texts of the tag api pins, spec.Legal. They are embedded in the binary and read by the tests of this package, so that they cannot fail to read.

func (*Texts) Current

func (t *Texts) Current(id string) (int32, bool)

Current is the number of the current version of the text id, and whether it has one.

func (*Texts) List

func (t *Texts) List(tag string) []*v1.LegalText

List is the texts of the place app in the language tag, as GetLegalTexts gives them.

func (*Texts) Names

func (t *Texts) Names(refs []*v1.LegalTextRef, ids ...string) bool

Names says whether refs names exactly the current version of each of ids that has one, and no other text: a text with no version in force is named by no request, and a version that is not current, a text in force left out, a text named twice or one that is none of ids is CAUSE_TEXT_NOT_CURRENT (contracts README, section 15).

func (*Texts) NamesOne

func (t *Texts) NamesOne(ref *v1.LegalTextRef, id string) bool

NamesOne is Names for a request that names a text by one field, ref, absent while the text has no version in force.

func (*Texts) Refs

func (t *Texts) Refs(ids ...string) []*v1.LegalTextRef

Refs is the reference to the current version of each of ids that has one, as a request that gives a consent to them names them.

Jump to

Keyboard shortcuts

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