client

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOpNotSupported = errors.New("client doesn't support this operation")

ErrOpNotSupported is returned by edge-only methods when the Client was not initialised with an edge (enterprise) connection.

Functions

This section is empty.

Types

type Client

type Client struct {
	*slack.Client // always set; promotes all Slack API methods
	// contains filtered or unexported fields
}

Client wraps *slack.Client and, optionally, *edge.Client. The edge client is only present for enterprise workspaces. All Slack interface methods are promoted from the embedded *slack.Client; edge-aware methods override them when c.edge is set.

func New

func New(ctx context.Context, prov auth.Provider, opts ...Option) (*Client, error)

New creates a new Client instance. It checks if workspace provider is valid, and checks if it's an enterprise workspace. If it is, it creates an edge client.

func NewEdge

func NewEdge(ctx context.Context, prov auth.Provider, opts ...Option) (*Client, error)

NewEdge returns a new *Client that is guaranteed to have an edge (enterprise) connection. Use c.Edge() to obtain the underlying *edge.Client.

func Wrap

func Wrap(cl *slack.Client) *Client

Wrap wraps a *slack.Client and returns a *Client that implements the Slack interface. Intended for testing.

func (*Client) AuthTestContext

func (c *Client) AuthTestContext(ctx context.Context) (*slack.AuthTestResponse, error)

AuthTestContext returns the cached workspace information that was captured on initialisation. If the cache is empty it calls the API.

func (*Client) Edge added in v4.0.2

func (c *Client) Edge() *edge.Client

Edge returns the underlying *edge.Client, or nil when the workspace is not an enterprise workspace.

func (*Client) GetConversationInfoContext added in v4.1.1

func (c *Client) GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)

GetConversationInfoContext overrides the standard method with the edge client for enterprise workspaces.

func (*Client) GetConversationsContext added in v4.1.1

func (c *Client) GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) ([]slack.Channel, string, error)

GetConversationsContext overrides the standard method with the edge client for enterprise workspaces.

func (*Client) GetConversationsContextEx added in v4.1.1

func (c *Client) GetConversationsContextEx(ctx context.Context, params *slack.GetConversationsParameters, onlyMy bool) ([]slack.Channel, string, error)

GetConversationsContextEx is the extended variant that supports the onlyMy parameter available in enterprise workspaces. Returns ErrOpNotSupported when there is no edge client.

func (*Client) GetUsersInConversationContext added in v4.1.1

func (c *Client) GetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)

GetUsersInConversationContext overrides the standard method with the edge client for enterprise workspaces.

type Option

type Option func(*options)

func WithEnterprise

func WithEnterprise(enterprise bool) Option

WithEnterprise sets the enterprise flag. Setting the flag to true forces the use of the edge client, even if the workspace is not an enterprise workspace.

type Pool

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

Pool is a pool of Slack clients that can be used to make API calls. Zero value is not usable, must be initialised with NewPool.

IMPORTANT: Every method on the Slack interface must be delegated here. When new methods are added to Slack, add the corresponding delegation below. A compile-time assertion below catches interface drift.

func NewPool

func NewPool(scl ...Slack) *Pool

NewPool wraps the slack.Client with the edge client, so that the edge client can be used as a fallback.

func (*Pool) AuthTestContext

func (p *Pool) AuthTestContext(ctx context.Context) (response *slack.AuthTestResponse, err error)

func (*Pool) GetConversationInfoContext

func (p *Pool) GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)

func (*Pool) GetConversationRepliesContext

func (p *Pool) GetConversationRepliesContext(ctx context.Context, params *slack.GetConversationRepliesParameters) (msgs []slack.Message, hasMore bool, nextCursor string, err error)

func (*Pool) GetConversationsContext

func (p *Pool) GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) (channels []slack.Channel, nextCursor string, err error)

func (*Pool) GetEmojiContext

func (p *Pool) GetEmojiContext(ctx context.Context) (map[string]string, error)

func (*Pool) GetFileContext

func (p *Pool) GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error

func (*Pool) GetFileInfoContext

func (p *Pool) GetFileInfoContext(ctx context.Context, fileID string, count int, page int) (*slack.File, []slack.Comment, *slack.Paging, error)

func (*Pool) GetStarredContext

func (p *Pool) GetStarredContext(ctx context.Context, params slack.StarsParameters) ([]slack.StarredItem, *slack.Paging, error)

func (*Pool) GetUserInfoContext

func (p *Pool) GetUserInfoContext(ctx context.Context, user string) (*slack.User, error)

func (*Pool) GetUserProfileContext

func (w *Pool) GetUserProfileContext(ctx context.Context, params *slack.GetUserProfileParameters) (*slack.UserProfile, error)

func (*Pool) GetUsersContext

func (p *Pool) GetUsersContext(ctx context.Context, options ...slack.GetUsersOption) ([]slack.User, error)

func (*Pool) GetUsersInConversationContext

func (p *Pool) GetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)

func (*Pool) GetUsersPaginated

func (p *Pool) GetUsersPaginated(options ...slack.GetUsersOption) slack.UserPagination

func (*Pool) ListBookmarks

func (p *Pool) ListBookmarks(channelID string) ([]slack.Bookmark, error)

func (*Pool) SearchFilesContext

func (p *Pool) SearchFilesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchFiles, error)

func (*Pool) SearchMessagesContext

func (p *Pool) SearchMessagesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchMessages, error)

type Slack

type Slack interface {
	AuthTestContext(ctx context.Context) (response *slack.AuthTestResponse, err error)
	GetConversationHistoryContext(ctx context.Context, params *slack.GetConversationHistoryParameters) (*slack.GetConversationHistoryResponse, error)
	GetConversationInfoContext(ctx context.Context, input *slack.GetConversationInfoInput) (*slack.Channel, error)
	GetConversationRepliesContext(ctx context.Context, params *slack.GetConversationRepliesParameters) (msgs []slack.Message, hasMore bool, nextCursor string, err error)
	GetConversationsContext(ctx context.Context, params *slack.GetConversationsParameters) (channels []slack.Channel, nextCursor string, err error)
	GetEmojiContext(ctx context.Context) (map[string]string, error)
	GetFileContext(ctx context.Context, downloadURL string, writer io.Writer) error
	GetFileInfoContext(ctx context.Context, fileID string, count int, page int) (*slack.File, []slack.Comment, *slack.Paging, error)
	GetStarredContext(ctx context.Context, params slack.StarsParameters) ([]slack.StarredItem, *slack.Paging, error)
	GetUserInfoContext(ctx context.Context, user string) (*slack.User, error)
	GetUsersContext(ctx context.Context, options ...slack.GetUsersOption) ([]slack.User, error)
	GetUsersInConversationContext(ctx context.Context, params *slack.GetUsersInConversationParameters) ([]string, string, error)
	GetUsersPaginated(options ...slack.GetUsersOption) slack.UserPagination
	ListBookmarks(channelID string) ([]slack.Bookmark, error)
	SearchFilesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchFiles, error)
	SearchMessagesContext(ctx context.Context, query string, params slack.SearchParameters) (*slack.SearchMessages, error)
	GetUserProfileContext(ctx context.Context, params *slack.GetUserProfileParameters) (*slack.UserProfile, error)
}

Slack is an interface that defines the methods that a Slack client should provide.

Directories

Path Synopsis
Package mock_client is a generated GoMock package.
Package mock_client is a generated GoMock package.

Jump to

Keyboard shortcuts

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