NewQuestionTemplate new question template
(ctx context.Context, raw *schema.NewQuestionTemplateRawData)
| 329 | |
| 330 | // NewQuestionTemplate new question template |
| 331 | func (es *EmailService) NewQuestionTemplate(ctx context.Context, raw *schema.NewQuestionTemplateRawData) ( |
| 332 | title, body string, err error) { |
| 333 | siteInfo, err := es.siteInfoService.GetSiteGeneral(ctx) |
| 334 | if err != nil { |
| 335 | return |
| 336 | } |
| 337 | seoInfo, err := es.siteInfoService.GetSiteSeo(ctx) |
| 338 | if err != nil { |
| 339 | return |
| 340 | } |
| 341 | templateData := &schema.NewQuestionTemplateData{ |
| 342 | SiteName: siteInfo.Name, |
| 343 | QuestionTitle: raw.QuestionTitle, |
| 344 | Tags: strings.Join(raw.Tags, ", "), |
| 345 | UnsubscribeUrl: fmt.Sprintf("%s/users/unsubscribe?code=%s", siteInfo.SiteUrl, raw.UnsubscribeCode), |
| 346 | } |
| 347 | templateData.QuestionUrl = display.QuestionURL( |
| 348 | seoInfo.Permalink, siteInfo.SiteUrl, raw.QuestionID, raw.QuestionTitle) |
| 349 | |
| 350 | lang := handler.GetLangByCtx(ctx) |
| 351 | title = translator.TrWithData(lang, constant.EmailTplKeyNewQuestionTitle, templateData) |
| 352 | body = translator.TrWithData(lang, constant.EmailTplKeyNewQuestionBody, &schema.NewQuestionTemplateData{ |
| 353 | SiteName: escapeEmailHTMLText(templateData.SiteName), |
| 354 | QuestionTitle: escapeEmailHTMLText(templateData.QuestionTitle), |
| 355 | QuestionUrl: templateData.QuestionUrl, |
| 356 | Tags: escapeEmailHTMLText(templateData.Tags), |
| 357 | UnsubscribeUrl: templateData.UnsubscribeUrl, |
| 358 | }) |
| 359 | return title, body, nil |
| 360 | } |
| 361 | |
| 362 | func (es *EmailService) GetEmailConfig(ctx context.Context) (ec *EmailConfig, err error) { |
| 363 | emailConf, err := es.configService.GetStringValue(ctx, constant.EmailConfigKey) |
no test coverage detected