summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/block_context.go
blob: c37bf27e986bf0402e438bf5c8d75f5361b5e3b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package slack

// ContextBlock defines data that is used to display message context, which can
// include both images and text.
//
// More Information: https://api.slack.com/reference/messaging/blocks#actions
type ContextBlock struct {
	Type            MessageBlockType `json:"type"`
	BlockID         string           `json:"block_id,omitempty"`
	ContextElements ContextElements  `json:"elements"`
}

// BlockType returns the type of the block
func (s ContextBlock) BlockType() MessageBlockType {
	return s.Type
}

type ContextElements struct {
	Elements []MixedElement
}

// NewContextBlock returns a new instance of a context block
func NewContextBlock(blockID string, mixedElements ...MixedElement) *ContextBlock {
	elements := ContextElements{
		Elements: mixedElements,
	}
	return &ContextBlock{
		Type:            MBTContext,
		BlockID:         blockID,
		ContextElements: elements,
	}
}