Update all Go modules in backend/ and backend/_example/memory_store/ to their latest versions (chroma 2.27, go-redis 9.21, bbolt 1.5, slack 0.27, golang.org/x/* and others); re-tidy and re-vendor, keep the example module in sync. Hold github.com/go-chi/chi/v5 at v5.2.5: v5.3.0 deprecates middleware.RealIP (IP-spoofing advisories). Switching off RealIP changes how the client IP is derived for rate limiting and votes, which is a security decision better made on its own rather than inside a dependency bump. go test -race, go vet, golangci-lint and govulncheck all clean on both modules.
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package slack
|
|
|
|
// HeaderBlock defines a new block of type header
|
|
//
|
|
// More Information: https://api.slack.com/reference/messaging/blocks#header
|
|
type HeaderBlock struct {
|
|
Type MessageBlockType `json:"type"`
|
|
Text *TextBlockObject `json:"text,omitempty"`
|
|
BlockID string `json:"block_id,omitempty"`
|
|
// Level sets the heading level. Values 1-4 correspond to H1-H4 heading
|
|
// levels, respectively.
|
|
Level int `json:"level,omitempty"`
|
|
}
|
|
|
|
// BlockType returns the type of the block
|
|
func (s HeaderBlock) BlockType() MessageBlockType {
|
|
return s.Type
|
|
}
|
|
|
|
// ID returns the ID of the block
|
|
func (s HeaderBlock) ID() string {
|
|
return s.BlockID
|
|
}
|
|
|
|
// HeaderBlockOption allows configuration of options for a new header block
|
|
type HeaderBlockOption func(*HeaderBlock)
|
|
|
|
func HeaderBlockOptionBlockID(blockID string) HeaderBlockOption {
|
|
return func(block *HeaderBlock) {
|
|
block.BlockID = blockID
|
|
}
|
|
}
|
|
|
|
// HeaderBlockOptionLevel sets the heading level of the header block. Values 1-4
|
|
// correspond to H1-H4 heading levels, respectively.
|
|
func HeaderBlockOptionLevel(level int) HeaderBlockOption {
|
|
return func(block *HeaderBlock) {
|
|
block.Level = level
|
|
}
|
|
}
|
|
|
|
// NewHeaderBlock returns a new instance of a header block to be rendered
|
|
func NewHeaderBlock(textObj *TextBlockObject, options ...HeaderBlockOption) *HeaderBlock {
|
|
block := HeaderBlock{
|
|
Type: MBTHeader,
|
|
Text: textObj,
|
|
}
|
|
|
|
for _, option := range options {
|
|
if option != nil {
|
|
option(&block)
|
|
}
|
|
}
|
|
|
|
return &block
|
|
}
|