Bumps the go-modules-updates group in /backend with 5 updates: | Package | From | To | | --- | --- | --- | | [github.com/PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery) | `1.10.0` | `1.10.1` | | [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) | `5.1.0` | `5.2.0` | | [github.com/go-pkgz/rest](https://github.com/go-pkgz/rest) | `1.19.0` | `1.20.2` | | [golang.org/x/image](https://github.com/golang/image) | `0.22.0` | `0.23.0` | | [golang.org/x/net](https://github.com/golang/net) | `0.31.0` | `0.33.0` | Updates `github.com/PuerkitoBio/goquery` from 1.10.0 to 1.10.1 - [Release notes](https://github.com/PuerkitoBio/goquery/releases) - [Commits](https://github.com/PuerkitoBio/goquery/compare/v1.10.0...v1.10.1) Updates `github.com/go-chi/chi/v5` from 5.1.0 to 5.2.0 - [Release notes](https://github.com/go-chi/chi/releases) - [Changelog](https://github.com/go-chi/chi/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-chi/chi/compare/v5.1.0...v5.2.0) Updates `github.com/go-pkgz/rest` from 1.19.0 to 1.20.2 - [Release notes](https://github.com/go-pkgz/rest/releases) - [Commits](https://github.com/go-pkgz/rest/compare/v1.19.0...v1.20.2) Updates `golang.org/x/image` from 0.22.0 to 0.23.0 - [Commits](https://github.com/golang/image/compare/v0.22.0...v0.23.0) Updates `golang.org/x/net` from 0.31.0 to 0.33.0 - [Commits](https://github.com/golang/net/compare/v0.31.0...v0.33.0) --- updated-dependencies: - dependency-name: github.com/PuerkitoBio/goquery dependency-type: direct:production update-type: version-update:semver-patch dependency-group: go-modules-updates - dependency-name: github.com/go-chi/chi/v5 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: github.com/go-pkgz/rest dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: golang.org/x/image dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor dependency-group: go-modules-updates ... Signed-off-by: dependabot[bot] <support@github.com>
86 lines
3.3 KiB
Go
86 lines
3.3 KiB
Go
package slack
|
|
|
|
// @NOTE: Blocks are in beta and subject to change.
|
|
|
|
// More Information: https://api.slack.com/block-kit
|
|
|
|
// MessageBlockType defines a named string type to define each block type
|
|
// as a constant for use within the package.
|
|
type MessageBlockType string
|
|
|
|
const (
|
|
MBTSection MessageBlockType = "section"
|
|
MBTDivider MessageBlockType = "divider"
|
|
MBTImage MessageBlockType = "image"
|
|
MBTAction MessageBlockType = "actions"
|
|
MBTContext MessageBlockType = "context"
|
|
MBTFile MessageBlockType = "file"
|
|
MBTInput MessageBlockType = "input"
|
|
MBTHeader MessageBlockType = "header"
|
|
MBTRichText MessageBlockType = "rich_text"
|
|
MBTCall MessageBlockType = "call"
|
|
MBTVideo MessageBlockType = "video"
|
|
)
|
|
|
|
// Block defines an interface all block types should implement
|
|
// to ensure consistency between blocks.
|
|
type Block interface {
|
|
BlockType() MessageBlockType
|
|
}
|
|
|
|
// Blocks is a convenience struct defined to allow dynamic unmarshalling of
|
|
// the "blocks" value in Slack's JSON response, which varies depending on block type
|
|
type Blocks struct {
|
|
BlockSet []Block `json:"blocks,omitempty"`
|
|
}
|
|
|
|
// BlockAction is the action callback sent when a block is interacted with
|
|
type BlockAction struct {
|
|
ActionID string `json:"action_id"`
|
|
BlockID string `json:"block_id"`
|
|
Type ActionType `json:"type"`
|
|
Text TextBlockObject `json:"text"`
|
|
Value string `json:"value"`
|
|
Files []File `json:"files"`
|
|
ActionTs string `json:"action_ts"`
|
|
SelectedOption OptionBlockObject `json:"selected_option"`
|
|
SelectedOptions []OptionBlockObject `json:"selected_options"`
|
|
SelectedUser string `json:"selected_user"`
|
|
SelectedUsers []string `json:"selected_users"`
|
|
SelectedChannel string `json:"selected_channel"`
|
|
SelectedChannels []string `json:"selected_channels"`
|
|
SelectedConversation string `json:"selected_conversation"`
|
|
SelectedConversations []string `json:"selected_conversations"`
|
|
SelectedDate string `json:"selected_date"`
|
|
SelectedTime string `json:"selected_time"`
|
|
SelectedDateTime int64 `json:"selected_date_time"`
|
|
InitialOption OptionBlockObject `json:"initial_option"`
|
|
InitialUser string `json:"initial_user"`
|
|
InitialChannel string `json:"initial_channel"`
|
|
InitialConversation string `json:"initial_conversation"`
|
|
InitialDate string `json:"initial_date"`
|
|
InitialTime string `json:"initial_time"`
|
|
}
|
|
|
|
// actionType returns the type of the action
|
|
func (b BlockAction) actionType() ActionType {
|
|
return b.Type
|
|
}
|
|
|
|
// NewBlockMessage creates a new Message that contains one or more blocks to be displayed
|
|
func NewBlockMessage(blocks ...Block) Message {
|
|
return Message{
|
|
Msg: Msg{
|
|
Blocks: Blocks{
|
|
BlockSet: blocks,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
// AddBlockMessage appends a block to the end of the existing list of blocks
|
|
func AddBlockMessage(message Message, newBlk Block) Message {
|
|
message.Msg.Blocks.BlockSet = append(message.Msg.Blocks.BlockSet, newBlk)
|
|
return message
|
|
}
|