getAdaptiveCard creates an Adaptive Card for Teams direct messages.
(context webhook.Context)
| 288 | |
| 289 | // getAdaptiveCard creates an Adaptive Card for Teams direct messages. |
| 290 | func getAdaptiveCard(context webhook.Context) *AdaptiveCard { |
| 291 | var body []any |
| 292 | |
| 293 | // Title |
| 294 | body = append(body, textBlock{ |
| 295 | Type: "TextBlock", |
| 296 | Text: context.Title, |
| 297 | Size: "Large", |
| 298 | Weight: "Bolder", |
| 299 | Wrap: true, |
| 300 | }) |
| 301 | |
| 302 | // Description |
| 303 | if context.Description != "" { |
| 304 | body = append(body, textBlock{ |
| 305 | Type: "TextBlock", |
| 306 | Text: context.Description, |
| 307 | Wrap: true, |
| 308 | }) |
| 309 | } |
| 310 | |
| 311 | // Facts (metadata) |
| 312 | var facts []fact |
| 313 | for _, meta := range context.GetMetaList() { |
| 314 | facts = append(facts, fact{ |
| 315 | Title: meta.Name, |
| 316 | Value: meta.Value, |
| 317 | }) |
| 318 | } |
| 319 | if context.ActorName != "" { |
| 320 | facts = append(facts, fact{ |
| 321 | Title: "Actor", |
| 322 | Value: fmt.Sprintf("%s (%s)", context.ActorName, context.ActorEmail), |
| 323 | }) |
| 324 | } |
| 325 | |
| 326 | if len(facts) > 0 { |
| 327 | body = append(body, factSet{ |
| 328 | Type: "FactSet", |
| 329 | Facts: facts, |
| 330 | }) |
| 331 | } |
| 332 | |
| 333 | // Actions |
| 334 | var actions []any |
| 335 | actions = append(actions, actionOpenURL{ |
| 336 | Type: "Action.OpenUrl", |
| 337 | Title: "View in Bytebase", |
| 338 | URL: context.Link, |
| 339 | }) |
| 340 | |
| 341 | return &AdaptiveCard{ |
| 342 | Type: "AdaptiveCard", |
| 343 | Version: "1.4", |
| 344 | Body: body, |
| 345 | Actions: actions, |
| 346 | } |
| 347 | } |
no test coverage detected