Add a function for get_webhooks()
This commit is contained in:
@ -51,7 +51,7 @@ from starlette.templating import _TemplateResponse
|
||||
|
||||
from discord_rss_bot.feeds import send_to_discord
|
||||
from discord_rss_bot.search import create_html_for_search_results
|
||||
from discord_rss_bot.settings import get_reader
|
||||
from discord_rss_bot.settings import get_reader, get_webhooks
|
||||
|
||||
app: FastAPI = FastAPI()
|
||||
app.mount("/static", StaticFiles(directory="discord_rss_bot/static"), name="static")
|
||||
@ -94,12 +94,7 @@ async def add_webhook(webhook_name: str = Form(), webhook_url: str = Form()) ->
|
||||
clean_webhook_url: str = webhook_url.strip()
|
||||
|
||||
# Get current webhooks from the database if they exist otherwise use an empty list.
|
||||
webhooks: list[dict[str, str]] = []
|
||||
if reader.get_tags(()) is not None:
|
||||
for tag in reader.get_tag_keys(()):
|
||||
if tag == "webhooks":
|
||||
webhooks = reader.get_tag((), "webhooks")
|
||||
break
|
||||
webhooks = get_webhooks(reader)
|
||||
|
||||
# Only add the webhook if it doesn't already exist.
|
||||
if not any(webhook["name"] == clean_webhook_name for webhook in webhooks):
|
||||
@ -134,12 +129,7 @@ async def delete_webhook(webhook_url: str = Form()) -> RedirectResponse | dict[s
|
||||
clean_webhook_url: str = webhook_url.strip()
|
||||
|
||||
# Get current webhooks from the database if they exist otherwise use an empty list.
|
||||
webhooks: list[dict[str, str]] = []
|
||||
if reader.get_tags(()) is not None:
|
||||
for tag in reader.get_tag_keys(()):
|
||||
if tag == "webhooks":
|
||||
webhooks = reader.get_tag((), "webhooks")
|
||||
break
|
||||
webhooks = get_webhooks(reader)
|
||||
|
||||
# Only add the webhook if it doesn't already exist.
|
||||
for webhook in webhooks:
|
||||
|
Reference in New Issue
Block a user