From fec7ac607178cf6cf79334d7517b558653df4733 Mon Sep 17 00:00:00 2001 From: YuehuCao Date: Fri, 25 Jul 2025 19:04:06 +0800 Subject: [PATCH] feat(tenant): enable customization of message templates and email senders --- .../backend/services/email_sender_service.py | 0 .../services/template_message_service.py | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 apps/notification/backend/services/email_sender_service.py create mode 100644 apps/notification/backend/services/template_message_service.py diff --git a/apps/notification/backend/services/email_sender_service.py b/apps/notification/backend/services/email_sender_service.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/notification/backend/services/template_message_service.py b/apps/notification/backend/services/template_message_service.py new file mode 100644 index 0000000..6c7ca21 --- /dev/null +++ b/apps/notification/backend/services/template_message_service.py @@ -0,0 +1,27 @@ +from backend.models.models import MessageTemplateDoc + +class TemplateMessageService: + async def get_template(self, template_id, tenant_id, region): + return await MessageTemplateDoc.find_one({ + "template_id": template_id, + "tenant_id": tenant_id, + "region": region, + "is_active": True + }) + + async def create_template(self, template:MessageTemplateDoc): + return await template.create() + + async def update_template(self, id: str, tenant_id: str, data: dict): + template = await MessageTemplateDoc.get(id) + if not template or template.tenant_id != tenant_id: + raise PermissionError("Forbidden") + await template.set(data) + return template + + async def delete_template(self, id: str, tenant_id: str): + template = await MessageTemplateDoc.get(id) + if not template or template.tenant_id != tenant_id: + raise PermissionError("Forbidden") + await template.delete() + return {"success": True} \ No newline at end of file