Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding (*adaptivecard.Message).AddElement method #297

Open
atc0005 opened this issue Aug 22, 2024 · 0 comments
Open

Consider adding (*adaptivecard.Message).AddElement method #297

atc0005 opened this issue Aug 22, 2024 · 0 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@atc0005
Copy link
Owner

atc0005 commented Aug 22, 2024

The method would add the given Element to the first card in the collection or an error if a Card is not already present.

The current alternatives:

msg, err := adaptivecard.NewSimpleMessage(msgText, msgTitle, true)
if err != nil {
	// ...
}

// element := ...
msg.Attachments[0].Content.Body = append(
	msg.Attachments[0].Content.Body,
	element,
)

or:

msg, err := adaptivecard.NewSimpleMessage(msgText, msgTitle, true)
if err != nil {
	// ...
}

// element := ...
msg.Attachments[0].Content.AddElement(false, element)

Because of the adaptivecard.NewSimpleMessage call we already know that a Card in msg.Attachments is present. While this allows us to safely take either of these approaches to add a new element to the first Card, it's not exactly ergonomic to do so.

Providing an AddElement method for the Message value would presumably make this scenario easier to work with.

@atc0005 atc0005 added enhancement New feature or request question Further information is requested labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant