dondaum commented on code in PR #58603:
URL: https://github.com/apache/airflow/pull/58603#discussion_r2654073353


##########
providers/discord/src/airflow/providers/discord/hooks/discord_webhook.py:
##########
@@ -70,21 +115,28 @@ def build_discord_payload(
                         (max 2000 characters)
         :param username: Override the default username of the webhook
         :param avatar_url: Override the default avatar of the webhook
+        :param embed: Discord embed object.
         :return: Discord payload (str) to send
         """
-        if len(message) > 2000:
-            raise ValueError("Discord message length must be 2000 or fewer 
characters.")
-        payload: dict[str, Any] = {
+        payload = {
             "content": message,
             "tts": tts,
         }
+        if len(message) > 2000:
+            raise ValueError("Discord message length must be 2000 or fewer 
characters.")
         if username:
             payload["username"] = username
         if avatar_url:
             payload["avatar_url"] = avatar_url
+        if embed:
+            payload["embeds"] = [self.validate_embed(embed=embed)]

Review Comment:
   `validate_embed()` technically validates, returns the `embed `and adds it to 
the `payload`. Whenever we move it up, we can separate the validation and the 
`embed `creation, but we would have two if blocks. In my opinion one if block 
is cleaner, but I'm open to changing it. WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to