MCPcopy Index your code
hub / github.com/apache/answer / NewCommentTemplate

Method NewCommentTemplate

internal/service/export/email_service.go:297–328  ·  view source on GitHub ↗

NewCommentTemplate new comment template

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

Source from the content-addressed store, hash-verified

295
296// NewCommentTemplate new comment template
297func (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
331func (es *EmailService) NewQuestionTemplate(ctx context.Context, raw *schema.NewQuestionTemplateRawData) (

Callers 1

Calls 6

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

Tested by

no test coverage detected