Add a function for get_webhooks()

This commit is contained in:
2022-12-19 17:23:55 +01:00
parent ddb8dea7a1
commit 372c5bb3e7
2 changed files with 22 additions and 13 deletions

View File

@ -45,3 +45,22 @@ def get_reader(custom_location: str = "") -> Reader:
"""
db_location: str = get_db_location(custom_location)
return make_reader(url=db_location)
def get_webhooks(reader: Reader) -> list[dict[str, str]]:
"""
Get current webhooks from the database if they exist otherwise use an empty list.
Args:
reader: The reader to use.
Returns:
list[dict[str, str]]: The webhooks.
"""
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
return webhooks