2
0
Files
logikonline 9e6d1d63de
All checks were successful
Build and Release / Create Release (push) Successful in 0s
Build and Release / Unit Tests (push) Successful in 3m10s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 5m5s
Build and Release / Lint (push) Successful in 5m20s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 2m54s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Successful in 9h4m29s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 8m14s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Successful in 8m19s
Build and Release / Build Binary (linux/arm64) (push) Successful in 8m27s
feat(blog): add comments, reactions, and guest verification
Implements threaded comment system with support for authenticated users and verified guests. Adds email verification flow for guest commenters with token-based sessions and 6-digit codes. Includes reaction system (like/love/laugh/etc) for posts and comments. Adds comment count to blog posts, user profile blog tab, and email notifications for comment verification. Implements nested reply support with parent-child relationships.
2026-02-01 22:22:18 -05:00

49 lines
1.4 KiB
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
package mailer
import (
"bytes"
"fmt"
"code.gitcaddy.com/server/v3/modules/log"
"code.gitcaddy.com/server/v3/modules/setting"
"code.gitcaddy.com/server/v3/modules/templates"
"code.gitcaddy.com/server/v3/modules/translation"
sender_service "code.gitcaddy.com/server/v3/services/mailer/sender"
)
const tplBlogCommentVerifyMail templates.TplName = "repo/blog_comment_verify"
// SendBlogCommentVerification sends a 6-digit verification code to a guest commenter.
func SendBlogCommentVerification(email, name, code, blogPostTitle string) error {
if setting.MailService == nil {
return nil
}
locale := translation.NewLocale("en-US")
subject := locale.TrString("mail.blog_comment.verify_subject", blogPostTitle)
mailMeta := map[string]any{
"locale": locale,
"Subject": subject,
"Name": name,
"Code": code,
"PostTitle": blogPostTitle,
"Language": locale.Language(),
}
var mailBody bytes.Buffer
if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, string(tplBlogCommentVerifyMail), mailMeta); err != nil {
log.Error("ExecuteTemplate [%s]: %v", string(tplBlogCommentVerifyMail)+"/body", err)
return fmt.Errorf("execute template: %w", err)
}
msg := sender_service.NewMessage(email, subject, mailBody.String())
msg.Info = subject
SendAsync(msg)
return nil
}