Skip to content

Commit

Permalink
msteams notifier: adaptive cards full width
Browse files Browse the repository at this point in the history
Configure the adaptive card to expand and make full use of extra canvas
space in teams.

Signed-off-by: Valentin Flaux <38909103+vflaux@users.noreply.github.com>
  • Loading branch information
vflaux committed Jan 13, 2025
1 parent d455ac6 commit 56c5a5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/notifier/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type msAdaptiveCardContent struct {
Type string `json:"type"`
Version string `json:"version"`
Body []msAdaptiveCardBodyElement `json:"body"`
MSTeams msAdaptiveCardMSTeams `json:"msteams"`
}

type msAdaptiveCardBodyElement struct {
Expand All @@ -98,6 +99,10 @@ type msAdaptiveCardContainer struct {
Items []msAdaptiveCardBodyElement `json:"items,omitempty"`
}

type msAdaptiveCardMSTeams struct {
Width string `json:"width,omitempty"`
}

type msAdaptiveCardTextBlock struct {
Text string `json:"text,omitempty"`
Size string `json:"size,omitempty"`
Expand Down Expand Up @@ -237,6 +242,9 @@ func buildMSTeamsAdaptiveCardPayload(event *eventv1.Event, objName string) *msAd
Schema: "http://adaptivecards.io/schemas/adaptive-card.json",
Type: "AdaptiveCard",
Version: msAdaptiveCardVersion,
MSTeams: msAdaptiveCardMSTeams{
Width: "Full",
},
Body: []msAdaptiveCardBodyElement{
{
Type: "Container",
Expand Down
3 changes: 3 additions & 0 deletions internal/notifier/teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func TestMSTeams_Post(t *testing.T) {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"msteams": map[string]any{
"width": "Full",
},
"body": []any{
map[string]any{
"type": "Container",
Expand Down

0 comments on commit 56c5a5a

Please sign in to comment.