draft

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 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 draft holds the Outbox drafts: posts the loop proposes and the user approves before they reach a provider.

Index

Constants

View Source
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

View Source
var ConversationKinds = []Kind{Reply, Nudge, Close, AskOwner, React}

ConversationKinds are the kinds slack_draft offers on a conversation: all but a review comment, an edit and a deletion, which slack_edit and slack_delete make at once.

View Source
var ErrTransition = errors.New("draft: transition not allowed")

ErrTransition is wrapped by Can.

View Source
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.

const (
	NoBroadcast  Broadcast = ""
	BroadcastOff Broadcast = "off"
	BroadcastOn  Broadcast = "on"
)

type Delivery

type Delivery string // "message", "reaction", "comment", "edit", "delete"

Delivery is how a draft reaches the provider.

const (
	Message         Delivery = "message"
	Reaction        Delivery = "reaction"
	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 ShapeOf

func ShapeOf(k Kind) (purpose string, d Delivery)

ShapeOf is the purpose and delivery of a draft of kind k.

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" 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
	// EffectsAppliedAt is when the Effects of a sent draft were applied;
	// zero while they are not.
	EffectsAppliedAt time.Time

	CreatedAt, UpdatedAt, SendingAt time.Time
}

func (Draft) Can

func (d Draft) Can(s State) error

Can says why d cannot move to s, nil when it can: held->queued|failed|dropped; queued->sending|failed|dropped; sending->sent|failed; failed->queued (by hand only)|dropped.

type Evidence

type Evidence struct {
	Ref       string // Slack: message ref, <conversation>/<ts>; GitHub: comment id
	Permalink string
	At        time.Time
}

type ID

type ID int64

type Kind

type Kind string // "reply", "nudge", "close", "react", "ask_owner", "comment", "edit", "delete"
const (
	Reply    Kind = "reply"
	Nudge    Kind = "nudge"
	Close    Kind = "close"
	React    Kind = "react"
	AskOwner Kind = "ask_owner"
	Comment  Kind = "comment"
	Edit     Kind = "edit"
	Delete   Kind = "delete"
)

func KindOf

func KindOf(purpose string, d Delivery) Kind

KindOf is the kind readers of Kind see for a purpose and a delivery.

func (Kind) Emoji

func (k Kind) Emoji() bool

Emoji says whether a draft of kind k posts an emoji, and no text.

func (Kind) Valid

func (k Kind) Valid() bool

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

type Placed struct {
	Target    string
	Broadcast Broadcast
}

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.

type State

type State string

State is where a draft's delivery stands, as the host keeps it; whether it may be posted at all is its gate's decision.

const (
	Held    State = "held"
	Queued  State = "queued"
	Sending State = "sending"
	Sent    State = "sent"
	Failed  State = "failed"
	Dropped State = "dropped"
)

Jump to

Keyboard shortcuts

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