slack

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const UserProfileCacheExpiry = 10 * time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertUpdateRequest

type AlertUpdateRequest struct {
	Alert alert.Alert
}

AlertUpdateRequest represents a request to update an alert message

type AlertUpdater

type AlertUpdater interface {
	UpdateAlert(ctx context.Context, alert alert.Alert)
	Stop()
}

AlertUpdater defines the interface for updating alert messages with rate limiting

func NewRateLimitedUpdater

func NewRateLimitedUpdater(client interfaces.SlackClient, opts ...UpdaterOption) AlertUpdater

NewRateLimitedUpdater creates a new rate-limited updater with optional configurations

type ConversationMessage added in v0.5.0

type ConversationMessage struct {
	User      *model.User
	Text      string
	Timestamp time.Time
	Thread    model.Thread
}

ConversationMessage represents a message from conversation history

type RateLimitedUpdater

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

RateLimitedUpdater provides rate-limited alert message updates

func (*RateLimitedUpdater) Stop

func (r *RateLimitedUpdater) Stop()

Stop gracefully stops the rate-limited updater

func (*RateLimitedUpdater) UpdateAlert

func (r *RateLimitedUpdater) UpdateAlert(ctx context.Context, alert alert.Alert)

UpdateAlert queues an alert update request asynchronously

type Service

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

func New

func New(client interfaces.SlackClient, channelID string, opts ...ServiceOption) (*Service, error)

func NewTestService

func NewTestService(t *testing.T) *Service

func (*Service) BotID

func (x *Service) BotID() string

func (*Service) ClearExpiredIconCache

func (x *Service) ClearExpiredIconCache()

ClearExpiredIconCache removes expired cache entries

func (*Service) ClearExpiredProfileCache

func (x *Service) ClearExpiredProfileCache()

ClearExpiredProfileCache removes expired profile cache entries

func (*Service) DefaultChannelID

func (x *Service) DefaultChannelID() string

func (*Service) GetChannelName

func (x *Service) GetChannelName(ctx context.Context, channelID string) (string, error)

GetChannelName returns the channel name for the given channel ID

func (*Service) GetClient

func (x *Service) GetClient() interfaces.SlackClient

GetClient returns the underlying SlackClient

func (*Service) GetConversationHistory added in v0.5.0

func (x *Service) GetConversationHistory(
	ctx context.Context,
	channelID string,
	threadID string,
	limit int,
	oldest int64,
) ([]ConversationMessage, error)

GetConversationHistory retrieves conversation history from Slack If threadID is provided, gets thread messages. Otherwise gets channel messages. limit: 0 means all messages, oldest: 0 means no time restriction

func (*Service) GetUserGroupName

func (x *Service) GetUserGroupName(ctx context.Context, groupID string) (string, error)

GetUserGroupName returns the user group name for the given group ID

func (*Service) GetUserIcon

func (x *Service) GetUserIcon(ctx context.Context, userID string) ([]byte, string, error)

GetUserIcon returns the user's icon image data

func (*Service) GetUserProfile

func (x *Service) GetUserProfile(ctx context.Context, userID string) (string, error)

GetUserProfile returns the user's profile name

func (*Service) IsBotUser

func (x *Service) IsBotUser(userID string) bool

func (*Service) NewThread

func (x *Service) NewThread(thread model.Thread) interfaces.SlackThreadService

func (*Service) PostAlert

func (x *Service) PostAlert(ctx context.Context, alert *alert.Alert) (interfaces.SlackThreadService, error)

func (*Service) PostMessage

func (x *Service) PostMessage(ctx context.Context, message string) (*ThreadService, error)

PostMessage posts a message to the channel and returns the thread. It's just for testing.

func (*Service) PostNotice added in v0.4.0

func (x *Service) PostNotice(ctx context.Context, channelID, message string, noticeID fmt.Stringer) (string, error)

PostNotice posts a notice message to Slack with an escalate button

func (*Service) PostNoticeThreadDetails added in v0.4.0

func (x *Service) PostNoticeThreadDetails(ctx context.Context, channelID, threadTS string, alert *alert.Alert, llmResponse *alert.GenAIResponse) error

PostNoticeThreadDetails posts detailed information about the notice in a thread

func (*Service) PostTicket

func (x *Service) PostTicket(ctx context.Context, ticket *ticket.Ticket, alerts alert.Alerts) (interfaces.SlackThreadService, string, error)

PostTicket posts a ticket to a new thread and returns the thread service

func (*Service) ShowBindToTicketModal

func (x *Service) ShowBindToTicketModal(ctx context.Context, callbackID model.CallbackID, tickets []*ticket.Ticket, triggerID string, metadata string) error

func (*Service) ShowEditTicketModal added in v0.5.0

func (x *Service) ShowEditTicketModal(ctx context.Context, ticket *ticket.Ticket, triggerID string) error

func (*Service) ShowResolveTicketModal

func (x *Service) ShowResolveTicketModal(ctx context.Context, ticket *ticket.Ticket, triggerID string, availableTags []*tag.Tag) error

func (*Service) ShowSalvageModal

func (x *Service) ShowSalvageModal(ctx context.Context, ticket *ticket.Ticket, unboundAlerts alert.Alerts, triggerID string) error

func (*Service) Stop

func (x *Service) Stop()

Stop gracefully stops the service and its rate-limited updater

func (*Service) TeamID

func (x *Service) TeamID() string

func (*Service) ToExternalMsgURL

func (x *Service) ToExternalMsgURL(channelID, threadID string) string

func (*Service) ToMsgURL

func (x *Service) ToMsgURL(channelID, threadID string) string

func (*Service) ToTicketURL

func (x *Service) ToTicketURL(ticketID string) string

ToTicketURL generates a URL to the ticket detail page in the frontend

func (*Service) UpdateAlerts

func (x *Service) UpdateAlerts(ctx context.Context, alerts alert.Alerts)

func (*Service) UpdateSalvageModal

func (x *Service) UpdateSalvageModal(ctx context.Context, ticket *ticket.Ticket, unboundAlerts alert.Alerts, viewID string, threshold float64, keyword string) error

type ServiceOption

type ServiceOption func(*Service)

ServiceOption represents a configuration option for Service

func WithFrontendURL

func WithFrontendURL(frontendURL string) ServiceOption

WithFrontendURL sets the frontend URL for generating ticket detail URLs

func WithUpdaterOptions

func WithUpdaterOptions(opts ...UpdaterOption) ServiceOption

WithUpdaterOptions sets options for the rate-limited updater

type ThreadService

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

func (*ThreadService) AttachFile

func (x *ThreadService) AttachFile(ctx context.Context, title, fileName string, data []byte) error

func (*ThreadService) ChannelID

func (x *ThreadService) ChannelID() string

func (*ThreadService) Entity

func (x *ThreadService) Entity() *model.Thread

func (*ThreadService) NewStateFunc

func (x *ThreadService) NewStateFunc(ctx context.Context, message string) func(ctx context.Context, msg string)

func (*ThreadService) NewTraceMessage added in v0.2.0

func (x *ThreadService) NewTraceMessage(ctx context.Context, initialMessage string) func(ctx context.Context, traceMsg string)

NewTraceMessage creates a new trace message function that posts new context blocks when byte limits are exceeded instead of updating existing ones

func (*ThreadService) NewUpdatableMessage added in v0.1.0

func (x *ThreadService) NewUpdatableMessage(ctx context.Context, initialMessage string) func(ctx context.Context, newMsg string)

func (*ThreadService) PostAlert

func (x *ThreadService) PostAlert(ctx context.Context, alert *alert.Alert) error

func (*ThreadService) PostAlertList

func (x *ThreadService) PostAlertList(ctx context.Context, list *alert.List) (string, error)

func (*ThreadService) PostAlertLists

func (x *ThreadService) PostAlertLists(ctx context.Context, clusters []*alert.List) error

func (*ThreadService) PostAlerts

func (x *ThreadService) PostAlerts(ctx context.Context, alerts alert.Alerts) error

func (*ThreadService) PostComment

func (x *ThreadService) PostComment(ctx context.Context, comment string) error

PostComment posts a simple text comment to the thread

func (*ThreadService) PostCommentWithMessageID

func (x *ThreadService) PostCommentWithMessageID(ctx context.Context, comment string) (string, error)

PostCommentWithMessageID posts a simple text comment to the thread and returns the message ID

func (*ThreadService) PostContextBlock added in v0.5.0

func (x *ThreadService) PostContextBlock(ctx context.Context, text string) error

PostContextBlock posts a message as a context block to the thread

func (*ThreadService) PostFinding

func (x *ThreadService) PostFinding(ctx context.Context, finding *ticket.Finding) error

func (*ThreadService) PostLinkToTicket

func (x *ThreadService) PostLinkToTicket(ctx context.Context, ticketURL, ticketTitle string) error

PostLinkToTicket posts a link to a ticket in the current thread

func (*ThreadService) PostResolveDetails added in v0.9.0

func (x *ThreadService) PostResolveDetails(ctx context.Context, t *ticket.Ticket) error

PostResolveDetails posts resolve details (conclusion and comment) to the thread

func (*ThreadService) PostSessionActions added in v0.9.0

func (x *ThreadService) PostSessionActions(ctx context.Context, ticketID types.TicketID, ticketStatus types.TicketStatus, sessionURL string) error

PostSessionActions posts session details link and Resolve/Edit action buttons to the thread

func (*ThreadService) PostTicket

func (x *ThreadService) PostTicket(ctx context.Context, ticket *ticket.Ticket, alerts alert.Alerts) (string, error)

func (*ThreadService) PostTicketList

func (x *ThreadService) PostTicketList(ctx context.Context, tickets []*ticket.Ticket) error

func (*ThreadService) Reply

func (x *ThreadService) Reply(ctx context.Context, message string)

func (*ThreadService) ThreadID

func (x *ThreadService) ThreadID() string

func (*ThreadService) ToExternalMsgURL

func (x *ThreadService) ToExternalMsgURL() string

func (ThreadService) ToMsgURL

func (x ThreadService) ToMsgURL(channelID, threadID string) string

func (*ThreadService) UpdateAlert

func (x *ThreadService) UpdateAlert(ctx context.Context, alert alert.Alert) error

func (*ThreadService) UpdateAlertList

func (x *ThreadService) UpdateAlertList(ctx context.Context, list *alert.List, status string) error

UpdateAlertList updates an alert list message with completion status

type UpdaterOption

type UpdaterOption func(*RateLimitedUpdater)

UpdaterOption represents a configuration option for RateLimitedUpdater

func WithInterval

func WithInterval(interval time.Duration) UpdaterOption

WithInterval sets the rate limiting interval

func WithRetryInterval

func WithRetryInterval(interval time.Duration) UpdaterOption

WithRetryInterval sets the base retry interval for exponential backoff

Jump to

Keyboard shortcuts

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