Documentation
¶
Overview ¶
Package draft holds the Outbox drafts: posts the loop proposes and the user approves before they reach a provider.
Index ¶
Constants ¶
const ( WithdrawAssigned = "assigned" WithdrawMoot = "moot" )
The reasons a workflow withdraws a draft it proposed, as Reason of the discarded draft: its person was assigned the items, or it is moot.
Variables ¶
var ErrTransition = errors.New("draft: transition not allowed")
ErrTransition is wrapped by Can.
var Kinds = []Kind{Reply, Nudge, Close, React, Unreact, AskOwner, Comment, Edit, Delete}
var Open = []State{Held, Queued, Sending}
Open are the states in which a draft may still be posted.
Functions ¶
This section is empty.
Types ¶
type Broadcast ¶ added in v0.4.0
type Broadcast string
Broadcast says whether a thread reply is also posted to its conversation. It is NoBroadcast when the draft replies in no thread, as its publisher places it when it is proposed.
type Delivery ¶
type Delivery string // "message", "reaction", "unreaction", "comment", "edit", "delete"
Delivery is how a draft reaches the provider.
const ( Message Delivery = "message" Reaction Delivery = "reaction" // Unreaction removes the user's reaction from a message. Unreaction Delivery = "unreaction" CommentDelivery Delivery = "comment" // EditDelivery replaces the text of a message the user posted. EditDelivery Delivery = "edit" // DeleteDelivery removes a message the user posted. DeleteDelivery Delivery = "delete" )
func (Delivery) ChangesAMessage ¶ added in v0.5.0
ChangesAMessage says whether a delivery edits or deletes a message.
type Draft ¶
type Draft struct {
ID ID
Unit unit.Unit
Items []string // item ids of Unit; may be empty
Task string // the task it serves, "" none; its row in the Outbox view is its draft gate
Kind Kind
Purpose string // what it is for: "nudge", "close", "ask_owner", or any label its proposer names
Delivery Delivery // how it is posted
Effects []string // applied when it is sent, such as "task.nudged"
Target string // plugin target grammar; "" means the unit itself (its thread, its PR)
Broadcast Broadcast // a thread reply also posted to its conversation; NoBroadcast when it replies in no thread
Text string // standard Markdown with mentions as @{<person key>}; the Effects implementation converts both; Kind "delete": the text of the message it removed, as Slack held it
Reaction string // Kind "react" or "unreact" only: emoji name without colons
Replaced string // Kind "edit" only: the text the edit replaced
Original string // Text as proposed
Edited bool // Text != Original
Origin Origin
State State
Evidence Evidence // State "sent" only
Error string // State "failed" only, never a token
Reason string // State "dropped": "user", "assigned", "moot", "dry_run", ...
Rev int64 // the stored row's version; every Update bumps it
// Payload is what the kind's schema shapes beside Text, nil for none.
Payload json.RawMessage
// Basis is what the proposer read the unit at, "" for none.
Basis string
// Hold keeps the draft waiting for the user whatever their approval rules say.
Hold bool
// EffectsAppliedAt is when the Effects of a sent draft were applied;
// zero while they are not.
EffectsAppliedAt time.Time
CreatedAt, UpdatedAt, SendingAt time.Time
}
type Kind ¶
type Kind string // "reply", "nudge", "close", "react", "unreact", "ask_owner", "comment", "edit", "delete"
type Origin ¶
type Origin struct {
Kind OriginKind
TurnSeq int64 // Kind "turn": the turn (session or headless) that proposed it; Kind "session": the handle's newest turn on the unit, 0 none
Intent string // the proposing turn's intent ("" for auto and user)
Workflow string // the workflow that started the proposing turn (turn.Turn.Workflow), "" none
Rule string // Kind "auto": the core or plugin rule, e.g. "stalled-nudge", "closure", "ask-owner", "github-nudge"
Key string // Kind "auto": the rule's dedupe key, e.g. "stalled-nudge:<task>:<person key>"
// Unit is the unit of the proposing turn when it is not the draft's, such
// as a pull request whose turn drafts in a Slack thread; zero when it is.
Unit unit.Unit
}
type OriginKind ¶
type OriginKind string // "turn", "session", "auto", "user"
const ( OriginTurn OriginKind = "turn" OriginSession OriginKind = "session" OriginAuto OriginKind = "auto" OriginUser OriginKind = "user" )
type Placed ¶ added in v0.4.0
Placed is where its publisher puts a draft when it is proposed: the target a draft with none posts to, "" for its unit, and its Broadcast.