slack

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PostIDInvalidChannel represents the post ID for issues with invalid channel ID
	PostIDInvalidChannel = "INVALID_CHANNEL_ID"
)

Variables

View Source
var ErrPendingPostUnresolved = errors.New("pending Slack post is not resolved yet")

ErrPendingPostUnresolved is returned by Client.Delete when the issue has a pending Slack post that was not found in the channel history yet, and the grace period has not elapsed. The post may still exist, so it can neither be deleted nor assumed to not exist. The issue is left unchanged, and the delete should be retried later.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(commandHandler FifoQueueProducer, cacheStore store.StoreInterface, logger types.Logger, metrics types.Metrics, cfg *config.ManagerConfig, managerSettings *models.ManagerSettingsWrapper, slackAPIClientOpts ...func(*internal.SlackAPIClient)) *Client

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, issue *models.Issue, reason string, updateIfMessageHasReplies bool) error

Delete deletes the Slack post of the issue, if any, and registers the post as deleted on the issue. If updateIfMessageHasReplies is true and the post has replies, the post is updated to look deleted instead. Errors where the channel or the message is no longer available are ignored.

A pending post (see models.Issue.SlackPostPendingSince) is looked up first. If the lookup fails, and the pending post has not expired, the error is returned (wrapping [errPendingPostLookup]). If the post is not found, and the grace period has not elapsed, ErrPendingPostUnresolved is returned, and the delete must be retried later.

func (*Client) DeletePost

func (c *Client) DeletePost(ctx context.Context, channelID, ts string) error

func (*Client) GetChannelName

func (c *Client) GetChannelName(ctx context.Context, channelID string) string

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(ctx context.Context, userID string) (*slack.User, error)

func (*Client) IsAlertChannel

func (c *Client) IsAlertChannel(ctx context.Context, channelID string) (bool, string, error)

func (*Client) NotifyWebhookOutcome added in v0.18.0

func (c *Client) NotifyWebhookOutcome(ctx context.Context, outcome *models.WebhookOutcome)

NotifyWebhookOutcome informs the user who clicked a webhook button about the webhook outcome.

If the webhook was confirmed in a modal (see models.WebhookOutcome.ViewID), the modal is updated with the outcome. If there is no modal, or it can't be updated (typically because the user has closed it), the outcome is reported in an ephemeral message if models.WebhookOutcome.NotifyWithoutModal is true, i.e. for failures, rejections and deliveries with a message from the receiving system. Plain deliveries are not reported.

Errors are logged, not returned.

func (*Client) OpenModal

func (c *Client) OpenModal(ctx context.Context, triggerID string, request slack.ModalViewRequest) error

func (*Client) PostEphemeral

func (c *Client) PostEphemeral(ctx context.Context, channelID, userID string, options ...slack.MsgOption) (string, error)

func (*Client) RunSocketMode

func (c *Client) RunSocketMode(ctx context.Context) error

func (*Client) SendResponse

func (c *Client) SendResponse(ctx context.Context, channelID, responseURL, responseType, text string) error

func (*Client) SetInsightsRecorder added in v0.16.0

func (c *Client) SetInsightsRecorder(recorder *insights.Recorder)

SetInsightsRecorder sets the recorder for Slack post insights events. A nil recorder disables recording. It must be called before the client is used.

func (*Client) SetIssueFinder

func (c *Client) SetIssueFinder(issueFinder IssueFinder)

func (*Client) SetIssueSaver added in v0.17.0

func (c *Client) SetIssueSaver(issueSaver IssueSaver)

SetIssueSaver sets the saver used to save an issue as pending before its Slack post is created (write-ahead). If the process crashes after the post is created, but before the issue is saved with the post ID, the post is then found in the channel history and adopted, rather than posted again. It is required, and must be called before Client.Connect.

func (*Client) SocketModeQuiet added in v0.4.0

func (c *Client) SocketModeQuiet() bool

SocketModeQuiet returns true when no Socket Mode event handlers are currently in flight. Used by the rate-limit gate's ready check.

func (*Client) Update

func (c *Client) Update(ctx context.Context, channelID string, allChannelIssues []*models.Issue) error

Update runs a channel update cycle for the non-archived issues in the channel: posts are deleted where requested (or for re-ordering), pending posts are looked up, and posts are created or updated where needed. A failed issue does not block the other issues, unless the error affects all Slack calls (see [abortsChannelUpdate]). All errors from the cycle are returned joined.

func (*Client) UpdateModal added in v0.18.0

func (c *Client) UpdateModal(ctx context.Context, viewID string, request slack.ModalViewRequest) error

UpdateModal replaces the content of an open modal view. It fails if the user has closed the modal.

func (*Client) UpdateSingleIssue

func (c *Client) UpdateSingleIssue(ctx context.Context, issue *models.Issue, reason string) error

UpdateSingleIssue creates or updates the Slack post for the issue, if the issue requires it (see models.Issue.GetSlackAction), unless the update is throttled (see [Client.throttleUpdate]). A pending post is looked up first (see [Client.resolvePendingPost]), and an error is returned if the lookup fails. Before a new post is created, the issue is saved to the database (see Client.SetIssueSaver).

func (*Client) UserIsInGroup

func (c *Client) UserIsInGroup(ctx context.Context, groupID, userID string) bool

type FifoQueueProducer

type FifoQueueProducer interface {
	Send(ctx context.Context, slackChannelID, dedupID, body string) error
}

type IssueFinder

type IssueFinder interface {
	FindIssueBySlackPost(ctx context.Context, channelID string, slackPostID string, includeArchived bool) *models.Issue
}

type IssueSaver added in v0.17.0

type IssueSaver interface {
	SaveIssue(ctx context.Context, issue types.Issue) error
}

IssueSaver saves an issue to the database. See Client.SetIssueSaver.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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