Lee-W commented on code in PR #58603:
URL: https://github.com/apache/airflow/pull/58603#discussion_r2652670595


##########
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.")

Review Comment:
   
   
   Why do we move it here? Originally we put it there as we want it to fail 
early



##########
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 = {

Review Comment:
   would like to know why did we remove type annotation?



##########
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:
   Would be better to move it above for early failing



##########
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)]
         return json.dumps(payload)
 
 
+if TYPE_CHECKING:
+    from airflow.providers.discord.notifications.embed import Embed

Review Comment:
   Let's move it to the top



-- 
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