NewCommentTemplate new comment template
(ctx context.Context, raw *schema.NewCommentTemplateRawData)
| 295 | |
| 296 | // NewCommentTemplate new comment template |
| 297 | func (es *EmailService) NewCommentTemplate(ctx context.Context, raw *schema.NewCommentTemplateRawData) ( |
| 298 | title, body string, err error) { |
| 299 | siteInfo, err := es.siteInfoService.GetSiteGeneral(ctx) |
| 300 | if err != nil { |
| 301 | return |
| 302 | } |
| 303 | seoInfo, err := es.siteInfoService.GetSiteSeo(ctx) |
| 304 | if err != nil { |
| 305 | return |
| 306 | } |
| 307 | templateData := &schema.NewCommentTemplateData{ |
| 308 | SiteName: siteInfo.Name, |
| 309 | DisplayName: raw.CommentUserDisplayName, |
| 310 | QuestionTitle: raw.QuestionTitle, |
| 311 | CommentSummary: raw.CommentSummary, |
| 312 | UnsubscribeUrl: fmt.Sprintf("%s/users/unsubscribe?code=%s", siteInfo.SiteUrl, raw.UnsubscribeCode), |
| 313 | } |
| 314 | templateData.CommentUrl = display.CommentURL(seoInfo.Permalink, |
| 315 | siteInfo.SiteUrl, raw.QuestionID, raw.QuestionTitle, raw.AnswerID, raw.CommentID) |
| 316 | |
| 317 | lang := handler.GetLangByCtx(ctx) |
| 318 | title = translator.TrWithData(lang, constant.EmailTplKeyNewCommentTitle, templateData) |
| 319 | body = translator.TrWithData(lang, constant.EmailTplKeyNewCommentBody, &schema.NewCommentTemplateData{ |
| 320 | SiteName: escapeEmailHTMLText(templateData.SiteName), |
| 321 | DisplayName: escapeEmailHTMLText(templateData.DisplayName), |
| 322 | QuestionTitle: escapeEmailHTMLText(templateData.QuestionTitle), |
| 323 | CommentUrl: templateData.CommentUrl, |
| 324 | CommentSummary: escapeEmailHTMLText(templateData.CommentSummary), |
| 325 | UnsubscribeUrl: templateData.UnsubscribeUrl, |
| 326 | }) |
| 327 | return title, body, nil |
| 328 | } |
| 329 | |
| 330 | // NewQuestionTemplate new question template |
| 331 | func (es *EmailService) NewQuestionTemplate(ctx context.Context, raw *schema.NewQuestionTemplateRawData) ( |
no test coverage detected