Documentation
¶
Overview ¶
Package slack implements Slack's OAuth and incoming-webhook protocol boundary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidGrant identifies a rejected or expired OAuth authorization code. ErrInvalidGrant = xerror.New(xerror.KindInvalidInput, "SLACK_INVALID_GRANT", "Slack OAuth grant was rejected") // ErrRateLimited identifies a Slack response that may be retried after the returned delay. ErrRateLimited = xerror.New(xerror.KindUnavailable, "SLACK_RATE_LIMITED", "Slack request was rate limited") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
*WebhookClient
// contains filtered or unexported fields
}
Client performs Slack OAuth and revocation requests.
func New ¶
New validates deployment configuration and creates a client that never follows redirects.
func (*Client) AuthorizationURL ¶
AuthorizationURL builds a consent URL requesting only Slack's incoming-webhook scope.
func (*Client) ExchangeCode ¶
ExchangeCode exchanges an OAuth authorization code for its Slack installation data.
type Config ¶
type Config struct {
ClientID string
ClientSecret string
RedirectURL string
HTTPClient *http.Client
}
Config contains deployment-owned Slack OAuth settings.
type Install ¶
type Install struct {
AccessToken string
Scope string
TeamID string
TeamName string
ChannelID string
ChannelName string
WebhookURL string
}
Install contains the fields from a successful incoming-webhook OAuth installation. WebhookURL is a credential and must only be persisted in secret storage.
type RateLimitError ¶
RateLimitError is safe to return to callers and preserves Slack's retry instruction.
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
func (*RateLimitError) Unwrap ¶
func (e *RateLimitError) Unwrap() error
type WebhookClient ¶
type WebhookClient struct {
// contains filtered or unexported fields
}
WebhookClient sends messages to Slack incoming-webhook URLs.
func NewWebhookClient ¶
func NewWebhookClient(client *http.Client) *WebhookClient
NewWebhookClient constructs a bounded client that never follows redirects.
func (*WebhookClient) SendWebhook ¶
func (c *WebhookClient) SendWebhook(ctx context.Context, webhookURL, text string) error
SendWebhook posts plain text to a webhook returned by Slack's OAuth response.