dondaum commented on code in PR #56911:
URL: https://github.com/apache/airflow/pull/56911#discussion_r2447283081
##########
providers/discord/src/airflow/providers/discord/hooks/discord_webhook.py:
##########
@@ -19,10 +19,70 @@
import json
import re
-from typing import Any
+from typing import TYPE_CHECKING, Any
+
+import aiohttp
from airflow.exceptions import AirflowException
-from airflow.providers.http.hooks.http import HttpHook
+from airflow.providers.discord.version_compat import get_async_connection
+from airflow.providers.http.hooks.http import HttpAsyncHook, HttpHook
+
+if TYPE_CHECKING:
+ from airflow.providers.discord.version_compat import Connection
+
+
+class DiscordCommonHandler:
+ """Contains the common functionality."""
+
+ def get_webhook_endpoint(self, conn: Connection | None, webhook_endpoint:
str | None) -> str:
+ """
+ Return the default webhook endpoint or override if a webhook_endpoint
is manually supplied.
+
+ :param conn: Airflow Discord connection
+ :param webhook_endpoint: The manually provided webhook endpoint
+ :return: Webhook endpoint (str) to use
+ """
+ if webhook_endpoint:
+ endpoint = webhook_endpoint
+ elif conn:
+ extra = conn.extra_dejson
+ endpoint = extra.get("webhook_endpoint", "")
+ else:
+ raise AirflowException(
Review Comment:
Thank you for your review.
I didn't change this part of the code, I just moved it to another class.
But I am happy to change it.
Done.
--
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]