MCPcopy Create free account
hub / github.com/apache/answer / NewQuestionTemplate

Method NewQuestionTemplate

internal/service/export/email_service.go:331–360  ·  view source on GitHub ↗

NewQuestionTemplate new question template

(ctx context.Context, raw *schema.NewQuestionTemplateRawData)

Source from the content-addressed store, hash-verified

329
330// NewQuestionTemplate new question template
331func (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
362func (es *EmailService) GetEmailConfig(ctx context.Context) (ec *EmailConfig, err error) {
363 emailConf, err := es.configService.GetStringValue(ctx, constant.EmailConfigKey)

Callers 1

Calls 6

QuestionURLFunction · 0.92
GetLangByCtxFunction · 0.92
TrWithDataFunction · 0.92
escapeEmailHTMLTextFunction · 0.85
GetSiteGeneralMethod · 0.65
GetSiteSeoMethod · 0.65

Tested by

no test coverage detected