slacknotifier

package
v0.15.14 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const NotificationsTypeSlack = "slack"

Variables

This section is empty.

Functions

func BuildRequestDetailMessage added in v0.11.1

func BuildRequestDetailMessage(o RequestDetailMessageOpts) (summary string, msg slack.Message)

Builds a contextual request detail message, with an optional HeadingMessage to be rendered in the header, this is fired after a request has been reviewed

func BuildRequestReviewMessage added in v0.12.0

func BuildRequestReviewMessage(o RequestMessageOpts) (summary string, msg slack.Message)

*

  • BuildRequestReviewMessage builds a slack message for a request review based on the contextual RequestMessageOpts

func SendMessage

func SendMessage(ctx context.Context, slackClient *slack.Client, userID, message, summary string, accessory *slack.Accessory) (timestamp string, error error)

SendMessage is a utility for sending DMs to users by ID

The message may be markdown formatted. The summary must be plaintext and is used as the fallback message in Slack notifications.

func SendMessageBlocks

func SendMessageBlocks(ctx context.Context, slackClient *slack.Client, userEmail string, message slack.Message, summary string) (timestamp string, error error)

SendMessageBlocks is a utility for sending DMs to users by ID

The message is in Slack message block format. The summary must be plaintext and is used as the fallback message in Slack notifications. The mesage is addressed to userEmail (therefore this is for DMs only, no webhook support)

Types

type RequestDetailMessageOpts added in v0.11.1

type RequestDetailMessageOpts struct {
	Request          access.Request
	RequestArguments []types.With
	Rule             rule.AccessRule
	// the message that renders in the header of the slack message
	HeadingMessage string
}

type RequestMessageOpts

type RequestMessageOpts struct {
	Request          access.Request
	RequestArguments []types.With
	Rule             rule.AccessRule
	ReviewURLs       notifiers.ReviewURLs
	// optional field that will replace the default requestor email with a slack @mention
	RequestorSlackID string
	RequestorEmail   string
	WasReviewed      bool
	RequestReviewer  *identity.User
	//Optional field for a user or group to be tagged in the message.
	MentionUser string
	IsWebhook   bool
}

type SlackDirectMessage

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

func (*SlackDirectMessage) Config

func (s *SlackDirectMessage) Config() gconfig.Config

func (*SlackDirectMessage) Init

func (s *SlackDirectMessage) Init(ctx context.Context) error

func (*SlackDirectMessage) TestConfig

func (s *SlackDirectMessage) TestConfig(ctx context.Context) error

type SlackIncomingWebhook

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

func (*SlackIncomingWebhook) Config

func (s *SlackIncomingWebhook) Config() gconfig.Config

func (*SlackIncomingWebhook) SendWebhookMessage

func (n *SlackIncomingWebhook) SendWebhookMessage(ctx context.Context, blocks slack.Blocks, summary string) error

type SlackNotifier

type SlackNotifier struct {
	DB          ddb.Storage
	FrontendURL string
	// contains filtered or unexported fields
}

SlackNotifier provides handler methods for sending notifications to Slack based on events. It has config for sending Slack DMs and/or messaging via Incoming Webhooks.

func (*SlackNotifier) HandleEvent

func (n *SlackNotifier) HandleEvent(ctx context.Context, event events.CloudWatchEvent) (err error)

func (*SlackNotifier) HandleGrantEvent

func (n *SlackNotifier) HandleGrantEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error

func (*SlackNotifier) HandleRequestEvent

func (n *SlackNotifier) HandleRequestEvent(ctx context.Context, log *zap.SugaredLogger, event events.CloudWatchEvent) error

func (*SlackNotifier) Init

func (n *SlackNotifier) Init(ctx context.Context, config *deploy.Notifications) error

func (*SlackNotifier) RenderRequestArguments

func (n *SlackNotifier) RenderRequestArguments(ctx context.Context, log *zap.SugaredLogger, request access.Request, rule rule.AccessRule) ([]types.With, error)

This method maps request arguments in a deprecated way. it should be replaced eventually with a cache lookup for the options available for the access rule

func (*SlackNotifier) SendDMWithLogOnError

func (n *SlackNotifier) SendDMWithLogOnError(ctx context.Context, log *zap.SugaredLogger, userId, msg, fallback string) (timestamp string)

SendDMWithLogOnError attempts to fetch a user from cognito to get their email, then tries to send them a message in slack, this is used to send PMs to users for updated access details

This will log any errors and continue

func (*SlackNotifier) SendTestMessage

func (sl *SlackNotifier) SendTestMessage(ctx context.Context, email string) error

SendTestMessage is a helper used for customers to test their slack integration settings

func (*SlackNotifier) SendUpdatesForRequest

func (n *SlackNotifier) SendUpdatesForRequest(ctx context.Context, log *zap.SugaredLogger, request access.Request, requestEvent gevent.RequestEventPayload, rule rule.AccessRule, requestingUser *identity.User)

func (*SlackNotifier) UpdateMessageBlockForReviewer

func (n *SlackNotifier) UpdateMessageBlockForReviewer(ctx context.Context, reviewer access.Reviewer, message slack.Message) error

UpdateMessageBlocks is a utility for updating DMs to users by ID

The message is in Slack message block format. userId is the reviewer

Jump to

Keyboard shortcuts

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