mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-23 17:22:56 -05:00
feat: add initial notification support
* Add updated recipe notification * Add recipe deleted notification * Add notifications translations * Shopping lists full c/u/d notifications * Add categories c/u/d notifications * Deal with None values in translation provider * Add tag c/u/d notifications * Add cookbook c/u/d notifications * use single key pairs for consistency with frontend * change dependency injection strategy * use generic update messages * use service to manage url generation server-side * use new strategies for messages * fix translator Co-authored-by: Miroito <alban.vachette@gmail.com>
This commit is contained in:
1
mealie/services/urls/__init__.py
Normal file
1
mealie/services/urls/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .url_constructors import *
|
||||
36
mealie/services/urls/url_constructors.py
Normal file
36
mealie/services/urls/url_constructors.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from pydantic import UUID4
|
||||
|
||||
from mealie.core.config import get_app_settings
|
||||
|
||||
|
||||
def _base_or(base_url: str | None) -> str:
|
||||
if base_url is None:
|
||||
settings = get_app_settings()
|
||||
return settings.BASE_URL
|
||||
|
||||
return base_url
|
||||
|
||||
|
||||
def recipe_url(recipe_slug: str, base_url: str | None) -> str:
|
||||
base = _base_or(base_url)
|
||||
return f"{base}/recipe/{recipe_slug}"
|
||||
|
||||
|
||||
def shopping_list_url(shopping_list_id: UUID4 | str, base_url: str | None) -> str:
|
||||
base = _base_or(base_url)
|
||||
return f"{base}/shopping-list/{shopping_list_id}"
|
||||
|
||||
|
||||
def tag_url(tag_slug: str, base_url: str | None) -> str:
|
||||
base = _base_or(base_url)
|
||||
return f"{base}/recipes/tags/{tag_slug}"
|
||||
|
||||
|
||||
def category_url(category_slug: str, base_url: str | None) -> str:
|
||||
base = _base_or(base_url)
|
||||
return f"{base}/recipes/categories/{category_slug}"
|
||||
|
||||
|
||||
def tool_url(tool_slug: str, base_url: str | None) -> str:
|
||||
base = _base_or(base_url)
|
||||
return f"{base}/recipes/tool/{tool_slug}"
|
||||
@@ -17,10 +17,10 @@ class RegistrationService:
|
||||
logger: Logger
|
||||
repos: AllRepositories
|
||||
|
||||
def __init__(self, logger: Logger, db: AllRepositories, t: Translator):
|
||||
def __init__(self, logger: Logger, db: AllRepositories, translator: Translator):
|
||||
self.logger = logger
|
||||
self.repos = db
|
||||
self.t = t
|
||||
self.t = translator.t
|
||||
|
||||
def _create_new_user(self, group: GroupInDB, new_group: bool) -> PrivateUser:
|
||||
new_user = UserIn(
|
||||
@@ -58,9 +58,9 @@ class RegistrationService:
|
||||
self.registration = registration
|
||||
|
||||
if self.repos.users.get_by_username(registration.username):
|
||||
raise HTTPException(status.HTTP_409_CONFLICT, {"message": self.t.t("exceptions.username-conflict-error")})
|
||||
raise HTTPException(status.HTTP_409_CONFLICT, {"message": self.t("exceptions.username-conflict-error")})
|
||||
elif self.repos.users.get(registration.email, "email"):
|
||||
raise HTTPException(status.HTTP_409_CONFLICT, {"message": self.t.t("exceptions.email-conflict-error")})
|
||||
raise HTTPException(status.HTTP_409_CONFLICT, {"message": self.t("exceptions.email-conflict-error")})
|
||||
|
||||
self.logger.info(f"Registering user {registration.username}")
|
||||
token_entry = None
|
||||
|
||||
Reference in New Issue
Block a user