slackapp

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 42 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 slackapp is the factory's Slack App (factory interfaces F9): a sponsored principal that drafts and files issues from a thread, a webhook subscriber that keeps the thread told, and the one surface that decides a forge.push approval — a card's two buttons, inside the same signed events door (v3.x Slack push approval §6), answered by the broker's decide route as the App's principal. It never relays room text, and no reply, reaction or message ever decides anything.

Index

Constants

This section is empty.

Variables

View Source
var ErrSignature = errors.New("slackapp: request not signed by Slack")

ErrSignature is any request that does not verify; it never says which check failed.

View Source
var ErrThreadTooLong = errors.New("slackapp: slack: the thread is too long")

ErrThreadTooLong is a thread with more pages than Thread follows: its latest draft cannot be known, so nothing is edited or filed from it.

View Source
var ErrUnknownTool = errors.New("slackapp: the broker does not offer this tool")

ErrUnknownTool is the broker without the tool asked: the self-serve link is off there.

View Source
var RequestedTextTooLong = errors.New("Not proposed: that request is longer than 16 KB; hand it off from your coding agent or the web UI.")

RequestedTextTooLong is a planner request past intake_plan's 16 KiB bound: a mention whose own text is, or a reply whose thread's first message is. Its text is the one line the thread shows: the person's fix is to hand the request off, not to shorten it in Slack, since a plan drawn from part of a request is a plan nobody read. The name and the prose are this package's interface rather than a caller's error to test, which is why they are not Go's Err-something form.

Functions

This section is empty.

Types

type App

type App struct {
	Slack       Slack
	Broker      BrokerAPI
	Threads     Threads
	Verifier    Verifier
	WebhookKeys func() ([][]byte, error)
	TeamID      string
	BotUserID   string
	RoomsURL    string
	Channels    map[string]Channel
	Proposals   Proposals    // the proposal flow's switch (CD7): on, a mention is planned and posted as one proposal
	Async       func(func()) // runs an event's handling after the 200 (tests); nil means the App's workers
	Now         func() time.Time
	Metrics     Recorder
	Logger      *slog.Logger
	// contains filtered or unexported fields
}

App is the flows: a mention drafts, the draft's author amends it with replies in its thread, a maintainer's check mark files, the broker's webhooks tell the thread, and — for forge.push only, where the channel's approvals flag is on — a card's button decides. A thread reply is read only to amend an unfiled draft; none is ever a command (invariant 8) and no reply is ever a decision.

func (*App) Events

func (a *App) Events() http.Handler

Events is the events listener's handler: the signature first, nothing read before it. Two body shapes arrive at this one door (D11, §6): Slack's JSON events and its form-encoded button presses, told apart by content type after the same verification.

func (*App) Wait added in v0.33.0

func (a *App) Wait(ctx context.Context) error

Wait stops taking events and returns once every queued and running one has finished, or ctx ends first: then it logs how many were left and returns the context's error, wrapped. Each of those was answered 200, so Slack will not resend it (F-10); the bound is the caller's, since 72 events at handleTimeout over eight workers can outlast a pod's grace period. Safe to call more than once.

func (*App) Webhooks

func (a *App) Webhooks() http.Handler

Webhooks is the webhooks listener's handler: the delivery is verified with the broker's keys (read at use) before it is decoded. It answers once the thread is told, so a Slack failure is a 502 and the broker's at-least-once retry brings the event back.

type ApprovalPayload added in v0.35.0

type ApprovalPayload struct {
	ApprovalID string `json:"approvalId"`
	Class      string `json:"class"`
	Branch     string `json:"branch"`
}

ApprovalPayload is a card's metadata (§5): what finds the card again without a search scope.

type Broker

type Broker struct {
	URL    string // the broker's base URL, from config only
	Tokens *Tokens
	HC     *http.Client // httpx.New in production
}

Broker is the room-broker's MCP endpoint, called as the App's own principal. It never calls tasks/*: the App follows a room through webhooks.

func (Broker) CoordinationDraft added in v0.39.0

CoordinationDraft is coordination_draft: the plan stored as its parent's draft, for the user. It confirms nothing; the parent is confirmed on its room page.

func (Broker) CoordinationPlan added in v0.39.0

CoordinationPlan is coordination_plan, the broker's governed multi-repository planner: it files nothing.

func (Broker) Decide added in v0.35.0

func (b Broker) Decide(ctx context.Context, d Decision) (DecisionResult, error)

Decide posts one press to the broker's human listener as the App's principal, with the same token cache and the same 401 retry every other call uses. The route answers a closed code with 200 for every refusal, so anything but 200 is transport, not a decision.

func (Broker) IntakePlan added in v0.36.0

func (b Broker) IntakePlan(ctx context.Context, in IntakeRequest) (IntakeResult, error)

IntakePlan is that tool's one call. The arguments are its schema's, and a key it does not have is never sent: a sponsored principal states whom it plans for and the channel's ceiling, and an argument the tool refuses would turn a plan into a transport failure. ErrUnknownTool comes back untouched, so an older broker answers the mention's own line rather than a draft (CD1).

func (Broker) IssueDraft

func (b Broker) IssueDraft(ctx context.Context, d Draft) (Draft, error)

IssueDraft asks the broker to judge a draft against the issue template.

func (Broker) NeedsList added in v0.36.0

func (b Broker) NeedsList(ctx context.Context, room string) ([]summary.Need, error)

NeedsList is needs_list for one room: the needs/v1 items alone, out of the envelope the route and the tool share. A sponsored caller reads a room's needs, never a login's, and each item's action is a link it cannot follow for anyone (CD26).

func (Broker) RoomChanges added in v0.36.0

func (b Broker) RoomChanges(ctx context.Context, room string) (roomview.ChangeSet, error)

RoomChanges is room_changes: the room's milestones since a cursor, which for a question is the last twenty-four hours without one — the same view 4 the room page's changes tab renders.

func (Broker) RoomSummary added in v0.36.0

func (b Broker) RoomSummary(ctx context.Context, room string) (summary.Summary, error)

RoomSummary is room_summary: the room's summary/v1 object, the one object the room page and maku status render, so a thread that asks where its task is reads what those two read (CD25). The room is the id the thread's Filed line named; the App never asks for a room it guessed.

func (Broker) RunCreate

func (b Broker) RunCreate(ctx context.Context, c RunCreate) (RunResult, error)

RunCreate files the run. Its arguments are run_create's schema exactly: `text` is the draft's body and dataClass is always public. A proposal adds `plan` and `plan_hash` — the pair the tool checks the confirmation against — and nothing else: a draft's arguments are the ones they always were, so an App that has no plan sends the call it always sent.

func (Broker) SlackLinkCode

func (b Broker) SlackLinkCode(ctx context.Context, team, user, handle, name string) (string, error)

SlackLinkCode asks the broker for a one-time link for the Slack user, handle and name shown on the page. The answer must be the link page with one code, or it is not passed on to the user.

func (b Broker) SlackUnlink(ctx context.Context, team, user string) (bool, error)

SlackUnlink asks the broker to remove the Slack user's link; unlinked is false when none was.

type BrokerAPI

type BrokerAPI interface {
	IssueDraft(ctx context.Context, d Draft) (Draft, error)
	RunCreate(ctx context.Context, c RunCreate) (RunResult, error)
	SlackLinkCode(ctx context.Context, team, user, handle, name string) (string, error)
	SlackUnlink(ctx context.Context, team, user string) (bool, error)
	// IntakePlan is the governed planner (CD18): a mention's words become the plan/v1 the proposal
	// message carries. It files nothing, and ErrUnknownTool is a broker without the tool.
	IntakePlan(ctx context.Context, in IntakeRequest) (IntakeResult, error)
	// Decide records one press of an approval's card, on the broker's decide route (§1): the only
	// thing the App decides, and only for forge.push.
	Decide(ctx context.Context, d Decision) (DecisionResult, error)
	// The three reads a filed thread's questions make (CD25): the room's summary, its changes and its
	// needs, each one sponsored call for the room the thread's Filed line named.
	RoomSummary(ctx context.Context, room string) (summary.Summary, error)
	RoomChanges(ctx context.Context, room string) (roomview.ChangeSet, error)
	NeedsList(ctx context.Context, room string) ([]summary.Need, error)
	// CoordinationPlan and CoordinationDraft are a two-repository mention's planner and its parent's
	// draft (v4): neither confirms, files nor runs anything.
	CoordinationPlan(ctx context.Context, in CoordinationPlanRequest) (CoordinationPlanResult, error)
	CoordinationDraft(ctx context.Context, parent string, in coordination.CoordinationConfirmation, onBehalfOf string) (coordination.CoordinationConfirmation, error)
}

BrokerAPI is what the flows call on the broker; Broker has it, and the test fakes it.

type Channel

type Channel struct {
	Repositories []string `json:"repositories"`
	MaxCostUSD   float64  `json:"maxCostUSD"`
	// Approvals draws this channel's forge.push approvals as a card with two buttons (v3.x Slack push
	// approval D14). Off, the thread keeps today's line and a press answers not_enabled.
	Approvals bool `json:"approvals,omitempty"`
	// Notify is which webhook transitions post a line in this channel (CD11). Absent means
	// webhook.Notify() — the nine a person is told about; an explicit empty list means none, which
	// is a choice, not an omission.
	Notify []string `json:"notify,omitempty"`
}

Channel is a channel the App serves: the repositories a draft there may name, the max_cost a ✅ there sends, whether its forge.push approvals are drawn as a card, and which webhook transitions post a line there (CD11, CD24 — declared once in ai-native-ref's slack-bindings.yaml).

type Config

type Config struct {
	TeamID            string             `json:"teamID"`
	BotUserIDFile     string             `json:"botUserIDFile"`
	BotTokenFile      string             `json:"botTokenFile"`
	SigningSecretFile string             `json:"signingSecretFile"`
	WebhookKeyFile    string             `json:"webhookKeyFile"`
	BrokerURL         string             `json:"brokerURL"`
	RoomsURL          string             `json:"roomsURL"`
	IssuerURL         string             `json:"issuerURL"`
	ClientIDFile      string             `json:"clientIDFile"`
	ClientSecretFile  string             `json:"clientSecretFile"`
	ProjectIDFile     string             `json:"projectIDFile"`
	Namespace         string             `json:"namespace"`
	Channels          map[string]Channel `json:"channels"`
	// Proposals is the proposal message's switch (CD7): off, a mention drafts as it does today.
	Proposals Proposals `json:"proposals,omitempty"`
	// The three listeners (M11): Slack's events (public), the broker's webhooks (cluster only),
	// and metrics with the probes. Defaults :8080, :8081 and :9090; a test passes 127.0.0.1:0.
	EventsAddr   string `json:"eventsAddr,omitempty"`
	WebhooksAddr string `json:"webhooksAddr,omitempty"`
	OpsAddr      string `json:"opsAddr,omitempty"`
}

Config is the App's config file, loaded strictly as the broker's config is.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads, strictly decodes, defaults and validates the file at path.

type ConfigMapThreads

type ConfigMapThreads struct {
	C         client.Client
	Namespace string
	Now       func() time.Time
	MaxBytes  int          // the encoded map's cap; defaults to 900 KiB (a ConfigMap holds 1 MiB)
	Logger    *slog.Logger // optional
}

ConfigMapThreads keeps the map in one ConfigMap: a key per room, the thread as JSON.

func (ConfigMapThreads) Get

func (m ConfigMapThreads) Get(ctx context.Context, room string) (Thread, bool, error)

Get is the thread a room was filed from, if any.

func (ConfigMapThreads) Put

func (m ConfigMapThreads) Put(ctx context.Context, room string, t Thread) error

Put records the thread and drops every entry older than 30 days. A conflict (another replica or a restart racing) re-reads and retries, three attempts in all.

type CoordinationPlanRequest added in v0.39.0

type CoordinationPlanRequest struct {
	Text, Context, Primary string
	Candidates             []string
	OnBehalfOf             string
	ID                     string `json:"id,omitempty"`
	Version                int32  `json:"version,omitempty"`
}

CoordinationPlanRequest is coordination_plan's arguments: the mention's words, the user's primary first, the two candidates, the user it plans for and, to replan, the draft's id and next version.

type CoordinationPlanResult added in v0.39.0

type CoordinationPlanResult struct {
	Plan        v1alpha1.CoordinationPlan           `json:"plan"`
	Hash        string                              `json:"hash"`
	Diagnostics []coordination.Diagnostic           `json:"diagnostics"`
	Planning    coordination.PlanningReconciliation `json:"planning"`
}

CoordinationPlanResult is coordination_plan's answer, as the broker serves it.

type CoordinationProposal added in v0.39.0

type CoordinationProposal struct {
	ParentTask string `json:"parentTask"`
	PlanHash   string `json:"planHash"`
	Version    int32  `json:"version"`
	Author     string `json:"author"`
}

CoordinationProposal is a coordination proposal's metadata: the parent, the hash and version the message shows, and the mention's author, who alone may revise it.

type Decision added in v0.35.0

type Decision struct {
	Team, User, Channel, MessageTS, ApprovalID, Branch, Decision string
}

Decision is one press, as POST /api/slack/decisions takes it (§1 of the design). The App fills it from the signed click only; no field comes from the card's text.

type DecisionResult added in v0.35.0

type DecisionResult struct{ Result string }

DecisionResult is the broker's closed code; Result is the decision when it recorded one.

type Draft

type Draft struct{ Repo, Title, Body string }

Draft is an issue as typed in a thread: the repository, the title and the body.

func ApplyReply

func ApplyReply(d Draft, text string) (out Draft, changed bool)

ApplyReply amends a draft with a reply in its thread: `Title:` replaces the title (the area rule applies again), `Should:` / `Expected:` and `Acceptance:` / `Done when:` / `Check:` replace their sections, any other text is appended to what is wrong. changed is false when the reply holds nothing to apply.

func ParseMention

func ParseMention(text, botUserID string, repos []string) (Draft, error)

ParseMention shapes a mention into a draft (R22): the text starts with <@botUserID>, line 1's rest is "[<owner/repo>] <title>" and composeBody turns the remaining lines into the template the factory's validator holds (the App adapts, the validator stays strict).

Where the channel serves exactly one repository, line 1 is the title alone (the repository named first, bare or in brackets, is still accepted), and a title that starts with something owner/name-shaped stays a title. Otherwise only is "".

type DraftPayload

type DraftPayload struct {
	Repo   string `json:"repo"`
	Title  string `json:"title"`
	Body   string `json:"body"`
	SHA256 string `json:"sha256"`
	// Author is the Slack user who wrote the mention: the only one whose thread replies edit the
	// draft. Rev counts the drafts the thread has had, 1 for the first.
	Author string `json:"author,omitempty"`
	Rev    int    `json:"rev,omitempty"`
}

DraftPayload is the checked draft and its hash, sha256 hex of repo, title and body joined by NUL.

type IntakeRequest added in v0.36.0

type IntakeRequest struct {
	Text       string
	Context    string
	OnBehalfOf string
	Candidates []string
	CeilingUSD float64
}

IntakeRequest is intake_plan's arguments, as the App has them: the requester's own words, the channel's repositories as the candidate set, the linked Slack user the plan is made for and the channel's ceiling. It carries no repository the App picked — the candidate set is the whole of what the App chooses, and which of it a plan names is the planner's, checked by the broker (CD5).

type IntakeResult added in v0.36.0

type IntakeResult struct {
	Plan        intake.Plan
	Hash        string
	Question    *intake.Question
	CanStart    bool
	CanStartWhy string
	Degraded    bool
}

IntakeResult is intake_plan's data: the plan the planner drew, the hash the broker computed over it, the at-most-one question to ask first, whether this caller may start the factory on it, and whether a template rather than the planner wrote it (CD18).

type MarkerPayload added in v0.36.0

type MarkerPayload struct {
	Repo      string `json:"repo"`
	Room      string `json:"room,omitempty"`
	Cancelled bool   `json:"cancelled,omitempty"`
}

MarkerPayload is the "Filed" line's tag: the repository that was filed and the room it started, so a thread that lost its map can still tell where the work went. Today's Filed lines carry the repository alone, which is why Room is optional — a decoder that required one would read every Filed line posted so far as a foreign message.

Cancelled marks the line a Cancel wrote: the proposal closed without filing anything, so its thread has no room and no question to answer (CD25).

type Message

type Message struct {
	TS, ThreadTS, User, Text string
	Metadata                 *Metadata
}

Message is a Slack message as the ✅ flow reads it (M9). User is who posted it: the App's own bot user for its drafts.

type Metadata

type Metadata struct {
	EventType    string          `json:"event_type"`
	EventPayload json.RawMessage `json:"event_payload"`
}

Metadata is what the App attaches to its own messages (R23); Slack keeps it off the visible text. EventPayload is tagged: the App decodes it on demand by EventType, so a card and a draft share one message shape (v3.x Slack push approval §5). A draft's bytes on the wire do not change.

type ProjectionRecorder added in v0.39.0

type ProjectionRecorder interface {
	CoordinationProjection(ctx context.Context, outcome string)
}

ProjectionRecorder counts slack_coordination_projection_total{outcome}; a Recorder that is not one counts nothing.

type ProposalPayload added in v0.36.0

type ProposalPayload struct {
	Plan   intake.Plan `json:"plan"`
	Hash   string      `json:"hash"`
	Author string      `json:"author"`
	Rev    int         `json:"rev"`
	// Degraded says the composer wrote this plan, not the planner (CD18). It rides the payload so the
	// message says it, and says it again after a restart that only has the message. It is display, not
	// material: the hash binds the plan, and the label is in no section's material set.
	Degraded bool `json:"degraded,omitempty"`
}

ProposalPayload is a proposal's metadata (CD20): the plan as the broker drew it, the hash a Confirm binds, who asked for it and which revision of the message this is. It is the whole of the proposal — no store, no memory of the thread — so an App that has just restarted reads the same proposal back from the message.

type Proposals added in v0.36.0

type Proposals struct {
	Enabled bool `json:"enabled,omitempty"`
}

Proposals is the proposal message's switch (CD7, CD20): on, a mention is planned by the broker and posted as one proposal edited in place; off, a mention drafts exactly as it does today. Absent is off, so a deployment that says nothing gets the behaviour it has.

type Question added in v0.36.0

type Question string

Question is one of the five things a filed proposal's thread answers, or the one word for everything else (CD25). The values are the counter's closed label set: one word per question, never a person's phrase, so slack_thread_answers_total{question} stays six series.

const (
	// QuestionStatus is where the task is: its phase and the room it is in.
	QuestionStatus Question = "status"
	// QuestionNeeds is what waits on a person in that room, the needs/v1 items.
	QuestionNeeds Question = "needs"
	// QuestionChanges is what happened recently, the room's milestones.
	QuestionChanges Question = "changes"
	// QuestionPR is the pull request the task opened, if it has one.
	QuestionPR Question = "pr"
	// QuestionStop is how to stop a run, which the App can only say, never do.
	QuestionStop Question = "stop"
	// QuestionUnknown is every phrase outside the vocabulary: answered with where things happen.
	QuestionUnknown Question = "unknown"
)

type Recorder

type Recorder interface {
	Request(ctx context.Context, route, outcome string)
	ProposalUpdate(ctx context.Context, action string)
	ThreadAnswer(ctx context.Context, question string)
}

Recorder counts requests for factory_slack_requests_total{route, outcome}, the proposal actions (proposal_updates_total{action}) and the answers a filed proposal's thread gives (thread_answers_total{question}). The two last are closed vocabularies the App passes: the instruments' names and their serving are metrics' (CD7, CD25).

type Refused

type Refused string

Refused is a tool's refusal ("rejected: <code>"), shown in the thread as is.

func (Refused) Error

func (r Refused) Error() string

type RunCreate

type RunCreate struct {
	Draft
	Plan       json.RawMessage // the plan/v1 the proposal bound, as its message carried it
	PlanHash   string          // intake.Hash of that plan
	MaxCostUSD float64
	OnBehalfOf string // slack:<team>/<user>
	Ref        string // slack/<team>/<channel>/<thread_ts>
	Key        string // the idempotency key
}

RunCreate is a draft filed as a run for the person who asked. Plan and PlanHash are set when the run is a proposal: the plan the message showed and the hash it bound, so the broker recomposes the plan from the fields it is sent, recomputes the hash over the plan's material set and refuses `plan_changed` when they disagree (CD20, CD27). A draft sets neither, and its arguments stay exactly what they were.

type RunResult

type RunResult struct {
	Room      string
	Issue     int
	Duplicate bool
	Sponsor   string
}

RunResult is what run_create answered: Sponsor is the GitHub login the factory filed as, "" when it did not say.

type Slack

type Slack interface {
	// Thread is the thread's messages, oldest first, the parent included, with their metadata.
	Thread(ctx context.Context, channel, threadTS string) ([]Message, error)
	Post(ctx context.Context, channel, threadTS, text string, meta *Metadata) (ts string, err error)
	// PostCard posts text with Block Kit blocks: the approval card and the conversational design's
	// proposal message ride it, so Post's own wire bytes do not move.
	PostCard(ctx context.Context, channel, threadTS, text string, blocks json.RawMessage, meta *Metadata) (ts string, err error)
	// Update rewrites a message the App posted (chat.update), for a card that must turn inert. Slack
	// refuses a message the App does not own; the error carries Slack's code.
	Update(ctx context.Context, channel, ts, text string, blocks json.RawMessage) error
	// UpdateProposal rewrites the one proposal message in place, its metadata included (CD7, CD20):
	// an edit never reposts, and the message the App reads back is the whole proposal.
	UpdateProposal(ctx context.Context, channel, ts, text string, blocks json.RawMessage, meta *Metadata) error
	Message(ctx context.Context, channel, ts string) (Message, error)
	// PostEphemeral is a message only user sees, in channel (and threadTS, when set).
	PostEphemeral(ctx context.Context, channel, user, threadTS, text string) error
	// UserName is the user's handle and display name, for the link page only; "" when Slack does
	// not say.
	UserName(ctx context.Context, user string) (handle, display string, err error)
}

Slack is the Web API calls the App makes.

type SlackClient

type SlackClient struct {
	BaseURL string // https://slack.com/api/ when empty
	Token   func() string
	HC      *http.Client // httpx.New in production
	Logger  *slog.Logger // Slack's error code on every failed call; discarded when nil
}

SlackClient is Slack's Web API over httpx. Token is read at use, so a rotated Secret applies.

func (*SlackClient) Message

func (c *SlackClient) Message(ctx context.Context, channel, ts string) (Message, error)

Message is conversations.replies for one ts (M9): the draft is a thread reply, which conversations.history never returns. The answer may also hold the thread's parent, so it keeps only the message whose ts is the one asked.

func (*SlackClient) Post

func (c *SlackClient) Post(ctx context.Context, channel, threadTS, text string, meta *Metadata) (string, error)

Post is chat.postMessage: no unfurling, the metadata attached when there is one.

func (*SlackClient) PostCard added in v0.35.0

func (c *SlackClient) PostCard(ctx context.Context, channel, threadTS, text string, blocks json.RawMessage, meta *Metadata) (string, error)

PostCard is chat.postMessage for a message that carries Block Kit blocks (§5, §6): the card's prose is its text, so a client without blocks still reads it. Separate from Post on purpose — Post's own call sites and the draft's wire bytes stay untouched.

func (*SlackClient) PostEphemeral

func (c *SlackClient) PostEphemeral(ctx context.Context, channel, user, threadTS, text string) error

PostEphemeral is chat.postEphemeral (chat:write): text that only user sees, never stored in the channel's history.

func (*SlackClient) Thread

func (c *SlackClient) Thread(ctx context.Context, channel, threadTS string) ([]Message, error)

Thread is conversations.replies for a thread, followed over a few pages at most.

func (*SlackClient) Update added in v0.35.0

func (c *SlackClient) Update(ctx context.Context, channel, ts, text string, blocks json.RawMessage) error

Update is chat.update (chat:write already covers it): it rewrites a message the App posted, in place. No metadata — an update is the App's own change to its own message, never a new tag — and no unfurling, as on Post. blocks replaces the message's own; empty leaves them as they are.

func (*SlackClient) UpdateProposal added in v0.36.0

func (c *SlackClient) UpdateProposal(ctx context.Context, channel, ts, text string, blocks json.RawMessage, meta *Metadata) error

UpdateProposal is chat.update for the proposal message (CD7, CD20): the App's own edit of its own message, carrying the metadata the message must hold afterwards. The blocks go when there are some, as on Update; the metadata is what makes the edited message still the proposal, so an edit that Slack refuses is the caller's to fall back from, never a silent repost.

func (*SlackClient) UserName

func (c *SlackClient) UserName(ctx context.Context, user string) (string, string, error)

UserName is users.info (users:read): the handle, unique in the workspace, and the profile's display name, else its real name (both set by the user). Without the scope Slack answers missing_scope, an error the caller shrugs off.

type SlackCoordinationProjection added in v0.39.0

type SlackCoordinationProjection struct {
	Outcome string
	Lines   []string
}

SlackCoordinationProjection is what one channel may be told of a family, as Slack lines.

type Thread

type Thread struct {
	Channel string    `json:"channel"`
	TS      string    `json:"ts"`
	At      time.Time `json:"at"`
	// Coordination marks a coordination parent's thread (v4): its deliveries are recomputed against
	// the channel at every event (projectCoordination), never posted as a single room's line.
	Coordination bool `json:"coordination,omitempty"`
}

Thread is where a room filed from Slack is followed (R25). At is when it was put, for the 30-day prune.

type Threads

type Threads interface {
	Put(ctx context.Context, room string, t Thread) error
	Get(ctx context.Context, room string) (Thread, bool, error)
}

Threads is the thread map, the ConfigMap factory-slack-threads in production.

type Tokens

type Tokens struct {
	Fetch func(ctx context.Context) (*oauth2.Token, error)
	// contains filtered or unexported fields
}

Tokens caches the App's client-credentials token until it expires or the broker refuses it (L9): clientcredentials' own TokenSource reuses a token until it expires and cannot be told that the broker refused it. Fetch should go through httpx (oauth2.HTTPClient in the context).

func (*Tokens) Invalidate

func (s *Tokens) Invalidate()

Invalidate drops the cached token after a 401, so the retry fetches a new one.

func (*Tokens) Token

func (s *Tokens) Token(ctx context.Context) (string, error)

Token is the cached access token, fetched when there is none or it expired.

type Verifier

type Verifier struct {
	Secret func() string
	Now    func() time.Time
}

Verifier checks Slack's v0 request signature (R27). Secret is read at use: a rotation is a Secret update and a restart-free reload.

func (Verifier) Body

func (v Verifier) Body(r *http.Request) ([]byte, error)

Body reads and verifies the request's body, returning it only when Slack signed it.

Jump to

Keyboard shortcuts

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