fix: Move Discord alert message to embed description field#368
Open
khj68 wants to merge 2 commits intografana:mainfrom
Open
fix: Move Discord alert message to embed description field#368khj68 wants to merge 2 commits intografana:mainfrom
khj68 wants to merge 2 commits intografana:mainfrom
Conversation
Previously, alert messages appeared above the title in Discord notifications because they were being sent in the 'content' field. This change: - Adds a 'description' field to the discordLinkEmbed struct - Moves the message content from the main 'content' field to the embed's 'description' field - Leaves the main 'content' field empty to avoid displaying text above the embed - Updates tests to reflect the new message structure This ensures that alert messages appear below the title in a properly formatted Discord embed, providing a better user experience. Fixes grafana/grafana#86565
…mentation Removed explanatory comments that were added during the implementation as they are no longer needed now that the code is self-explanatory.
Collaborator
|
Hey @khj68. Thanks for opening it. I am very sorry that it's been ignored for so long. Perhaps nobody just noticed it in this repository. We will improve, I promise. In the meantime, while I am reviewing the change, could you please rebase your fix on main and resolve the conflicts? |
| @@ -42,10 +42,11 @@ type discordMessage struct { | |||
|
|
|||
| // discordLinkEmbed implements https://discord.com/developers/docs/resources/channel#embed-object | |||
Collaborator
There was a problem hiding this comment.
Can you please change to https://discord.com/developers/docs/resources/message#embed-object-embed-structure
Collaborator
yuri-tceretian
left a comment
There was a problem hiding this comment.
LGTM! Thanks. Just needs rebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR fixes the Discord notification formatting issue where alert messages appear above the title instead of below it. The issue was caused by the message content being placed in the Discord message's main
contentfield rather than in the embed'sdescriptionfield.Changes:
Descriptionfield to thediscordLinkEmbedstruct to support embed descriptionsdescriptionfieldcontentfield to an empty string to prevent text from appearing above the embedWhich issue(s) this PR fixes
Fixes grafana/grafana#86565
Special notes for reviewer
The Discord API documentation specifies that the
contentfield appears outside of embeds, while the embed'sdescriptionfield appears below the title within the embed itself. This change aligns our implementation with Discord's expected behavior and matches what users see with other notification channels like Slack.Before:
After:
Checklist