Documentation
¶
Overview ¶
Package askref is an ask's REFERENCES: the drafts, officer items, posts and content entries an ask is about, as typed pointers (migration 0206, attention_asks.refs; docs/attention.md "Reference cards").
An ask stores only the pointer — {kind, id} or, for a post, {kind, url} — never a copy of what it points at. Every surface reads the thing it points at AT RENDER TIME, under the viewer's own principal (row-level security), and draws its CURRENT state (internal/api ask_refs.go): a draft the ask was raised about that has since been sent says "sent", so the person sees the ask is moot. A pointer the viewer cannot read, or that names nothing, draws nothing — never an error.
🔴 THE POINTERS ARE AN AGENT'S, SO UNTRUSTED. Parse is the one validation (kind enum, positive ids, https URLs only, at most MaxRefs): an officer's officer_complete and every other writer go through it, and a refusal names what to fix so the agent can retry.
Index ¶
Constants ¶
const ( // KindDraft is an outbound or reply draft (plugin_reply_drafts.id). KindDraft = "draft" // KindItem is an officer item (officer_items.id). KindItem = "item" // KindPost is a post already out on a venue: its https URL. KindPost = "post" // KindContentEntry is one scheduled post of an approved content set // (plugin_content_entries.id). KindContentEntry = "content_entry" )
The kinds a reference may name.
const MaxRefs = 5
MaxRefs is how many references one ask may carry (0206's CHECK holds it).
const MaxURLRunes = 500
MaxURLRunes bounds a post's URL.
Variables ¶
var Kinds = []string{KindDraft, KindItem, KindPost, KindContentEntry}
Kinds is every kind, in the order a refusal lists them.
Functions ¶
This section is empty.
Types ¶
type Ref ¶
type Ref struct {
Kind string `json:"kind"`
ID int64 `json:"id,omitempty"`
URL string `json:"url,omitempty"`
}
Ref is one reference: Kind and, for a post, URL; for every other kind ID.
func Clean ¶
func Clean(r Ref, rawID json.RawMessage) (out Ref, bad string)
Clean is r with its id taken from rawID (a JSON whole number, or a string of digits), checked: a known kind; a post with an https URL and no id; any other kind with a positive id and no URL. bad says why it is refused.
func CleanAll ¶
CleanAll is refs as a store keeps them: each Valid, none twice, at most MaxRefs; an error names the first that is not.
func Parse ¶
func Parse(raw json.RawMessage) ([]Ref, string)
Parse is raw — a JSON array of {kind, id} / {kind: "post", url} — as an ask stores it, or why it is refused (a sentence naming the bad element, worded for the agent that sent it). Absent, null and [] are no references. Duplicates are dropped.