1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768openLwt.SyntaxmoduleMake(Repo:Sihl_email_template_repo.Sig):Sihl_contract.Email_template.Sig=structletget~id=Repo.get~idletget_by_name~name=Repo.get_by_name~nameletcreate~name~html~text=lettemplate=Sihl_type.Email_template.make~text~htmlnameinlet*()=Repo.insert~templateinletid=Sihl_type.Email_template.idtemplateinlet*created=Repo.get~idinmatchcreatedwith|None->Logs.err(funm->m"EMAIL: Could not create template %a"Sihl_type.Email_template.pptemplate);raise(Sihl_type.Email.Exception"Could not create email template")|Somecreated->Lwt.returncreated;;letupdate~template=let*()=Repo.update~templateinletid=Sihl_type.Email_template.idtemplateinlet*created=Repo.get~idinmatchcreatedwith|None->Logs.err(funm->m"EMAIL: Could not update template %a"Sihl_type.Email_template.pptemplate);raise(Sihl_type.Email.Exception"Could not create email template")|Somecreated->Lwt.returncreated;;letrenderemail=lettemplate_id=Sihl_type.Email.template_idemailinlettemplate_data=Sihl_type.Email.template_dataemailinlettext_content=Sihl_type.Email.text_contentemailinlethtml_content=Sihl_type.Email.html_contentemailinlet*text_content,html_content=matchtemplate_idwith|Sometemplate_id->let*template=Repo.get~id:template_idinlet*template=matchtemplatewith|None->raise(Sihl_type.Email.Exception(Printf.sprintf"Template with id %s not found"template_id))|Sometemplate->Lwt.returntemplateinSihl_type.Email_template.rendertemplate_datatemplate|>Lwt.return|None->Lwt.return(text_content,html_content)inemail|>Sihl_type.Email.set_text_contenttext_content|>Sihl_type.Email.set_html_contenthtml_content|>Lwt.return;;letstart()=Lwt.return()letstop()=Lwt.return()letlifecycle=Sihl_core.Container.Lifecycle.create"template"~start~stopletregister()=Repo.register_migration();Repo.register_cleaner();Sihl_core.Container.Service.createlifecycle;;end