Files
Dmitry VerkhoturovandUmputun 45c17a913f chore(deps): bump go modules in backend and example
Backend (backend/go.mod):
- github.com/go-pkgz/auth/v2 v2.1.2 → v2.1.4
- github.com/klauspost/compress v1.18.5 → v1.18.6
- github.com/redis/go-redis/v9 v9.18.0 → v9.19.0
- github.com/slack-go/slack v0.21.1 → v0.23.1
- golang.org/x/crypto v0.50.0 → v0.51.0
- golang.org/x/image v0.39.0 → v0.40.0
- golang.org/x/net v0.53.0 → v0.54.0
- golang.org/x/sys v0.43.0 → v0.44.0
- golang.org/x/text v0.36.0 → v0.37.0

Example (backend/_example/memory_store/go.mod):
- golang.org/x/crypto v0.50.0 → v0.51.0
- golang.org/x/image v0.39.0 → v0.40.0
- golang.org/x/net v0.53.0 → v0.54.0
- golang.org/x/sys v0.43.0 → v0.44.0

Transitive cleanup: github.com/dgryski/go-rendezvous is no longer required
after redis/go-redis bump and gets pruned by `go mod tidy`.

`go mod tidy` + `go mod vendor` run on both modules. Both build with -race
and full test suites pass.
2026-05-20 20:09:47 -05:00

71 lines
1.9 KiB
Go

package slack
// AlertLevel defines the severity for an AlertBlock.
type AlertLevel string
const (
AlertLevelDefault AlertLevel = "default"
AlertLevelInfo AlertLevel = "info"
AlertLevelWarning AlertLevel = "warning"
AlertLevelError AlertLevel = "error"
AlertLevelSuccess AlertLevel = "success"
)
// AlertBlock defines a block of type alert used to surface a notification
// message with an optional severity level.
//
// Surface: modal only. Slack rejects alert blocks sent via chat.postMessage
// or the streaming APIs — use OpenView / UpdateView / PushView with a
// ModalViewRequest whose Blocks include the alert.
//
// More Information: https://docs.slack.dev/reference/block-kit/blocks/alert-block/
type AlertBlock struct {
Type MessageBlockType `json:"type"`
Text *TextBlockObject `json:"text"`
Level AlertLevel `json:"level,omitempty"`
BlockID string `json:"block_id,omitempty"`
}
// BlockType returns the type of the block
func (s AlertBlock) BlockType() MessageBlockType {
return s.Type
}
// ID returns the ID of the block
func (s AlertBlock) ID() string {
return s.BlockID
}
// AlertBlockOption allows configuration of options for a new alert block
type AlertBlockOption func(*AlertBlock)
// AlertBlockOptionLevel sets the severity level for the alert block
func AlertBlockOptionLevel(level AlertLevel) AlertBlockOption {
return func(block *AlertBlock) {
block.Level = level
}
}
// AlertBlockOptionBlockID sets the block ID for the alert block
func AlertBlockOptionBlockID(blockID string) AlertBlockOption {
return func(block *AlertBlock) {
block.BlockID = blockID
}
}
// NewAlertBlock returns a new instance of an alert block
func NewAlertBlock(text *TextBlockObject, options ...AlertBlockOption) *AlertBlock {
block := AlertBlock{
Type: MBTAlert,
Text: text,
}
for _, option := range options {
if option != nil {
option(&block)
}
}
return &block
}