Rename get_webhooks to list_webhooks

This commit is contained in:
2022-12-20 01:10:35 +01:00
parent 7713d4928b
commit 3503a17e04
2 changed files with 4 additions and 5 deletions

View File

@ -27,7 +27,6 @@ Functions:
Runs on startup.
"""
import urllib.parse
from datetime import datetime
from typing import Any, Iterable
import uvicorn
@ -51,7 +50,7 @@ from starlette.templating import _TemplateResponse # noqa
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, get_webhooks
from discord_rss_bot.settings import get_reader, list_webhooks
app: FastAPI = FastAPI()
app.mount("/static", StaticFiles(directory="discord_rss_bot/static"), name="static")
@ -94,7 +93,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 = get_webhooks(reader)
webhooks = list_webhooks(reader)
# Only add the webhook if it doesn't already exist.
if not any(webhook["name"] == clean_webhook_name for webhook in webhooks):
@ -128,7 +127,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 = get_webhooks(reader)
webhooks = list_webhooks(reader)
# Only add the webhook if it doesn't already exist.
for webhook in webhooks:

View File

@ -47,7 +47,7 @@ def get_reader(custom_location: str = "") -> Reader:
return make_reader(url=db_location)
def get_webhooks(reader: Reader) -> list[dict[str, str]]:
def list_webhooks(reader: Reader) -> list[dict[str, str]]:
"""
Get current webhooks from the database if they exist otherwise use an empty list.