feat(tenant): enable customization of message templates and email senders

This commit is contained in:
YuehuCao 2025-07-25 19:04:06 +08:00
parent 2637ee864a
commit fec7ac6071
2 changed files with 27 additions and 0 deletions

View File

@ -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}