feat(tenant): enable customization of message templates and email senders
This commit is contained in:
parent
2637ee864a
commit
fec7ac6071
@ -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}
|
||||
Loading…
Reference in New Issue
Block a user