| 1 | package slack |
| 2 | |
| 3 | // ContextBlock defines data that is used to display message context, which can |
| 4 | // include both images and text. |
| 5 | // |
| 6 | // More Information: https://api.slack.com/reference/messaging/blocks#context |
| 7 | type ContextBlock struct { |
| 8 | Type MessageBlockType `json:"type"` |
| 9 | BlockID string `json:"block_id,omitempty"` |
| 10 | ContextElements ContextElements `json:"elements"` |
| 11 | } |
| 12 | |
| 13 | // BlockType returns the type of the block |
| 14 | func (s ContextBlock) BlockType() MessageBlockType { |
| 15 | return s.Type |
| 16 | } |
| 17 | |
| 18 | type ContextElements struct { |
| 19 | Elements []MixedElement |
| 20 | } |
| 21 | |
| 22 | // NewContextBlock returns a new instance of a context block |
| 23 | func NewContextBlock(blockID string, mixedElements ...MixedElement) *ContextBlock { |
| 24 | elements := ContextElements{ |
| 25 | Elements: mixedElements, |
| 26 | } |
| 27 | return &ContextBlock{ |
| 28 | Type: MBTContext, |
| 29 | BlockID: blockID, |
| 30 | ContextElements: elements, |
| 31 | } |
| 32 | } |