summaryrefslogtreecommitdiff
path: root/internal/mailer
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <145215889+SayaAndy@users.noreply.github.com> 2026-05-18 01:33:14 +0700
committerGravatar GitHub <noreply@github.com> 2026-05-18 01:33:14 +0700
commit2c9d7e7c3110153c025c5324e0c4cc28d58cd2c1 (patch)
tree7d091ef937b8389d72ca3b0d28a6abaefb9c083e /internal/mailer
parent55f0ca98d42b3d540870dc1c9430b9a26ff19807 (diff)
parenta43cbea2e501371390709005055c019459554bb2 (diff)
downloadweb-0.16.0.tar.gz
web-0.16.0.zip
v0.16.0 (#40)v0.16.0
* [feat: all color themes now have light & dark variations depending on preference](https://github.com/SayaAndy/saya-today-web/commit/44b72cbc80fb89788470bda75eeb9c0bb3dee2f5) * [feat: use self-hosted pmtiles for map](https://github.com/SayaAndy/saya-today-web/commit/fa52ed00e8ef3303f14d7c953f1591eb19042635) * [feat: subheader for blog pages with medley-related ones](https://github.com/SayaAndy/saya-today-web/commit/c07da125bc5b0bb65f58c4edce912874e46f6ed8) * feat: color all leaflet elements depending on color theme & scheme * [feat: combined map widget](https://github.com/SayaAndy/saya-today-web/pull/40/commits/6418da32d978a8b70d38f1911a154e4dcc33202e) * feat: migrate static & photos to gcore cdn * [refactor: rewrite localization for dynamic set and get](https://github.com/SayaAndy/saya-today-web/commit/e9353a66bf51486f702eaa0f591dea54c9bd4cd1) * [feat: highlight the blog page visited earlier in blog catalogue](https://github.com/SayaAndy/saya-today-web/commit/ed476a1f0d3f970f977626688ac316f8b251d3a0) * fix: inline shadow now sticks to scrolling * [feat: take all metadata from centralized index.json](https://github.com/SayaAndy/saya-today-web/commit/1c441f5eab9a2a24fe5309178ce010f32adac1c7) * [fix: font in like button on smartphone screens](https://github.com/SayaAndy/saya-today-web/commit/551295ecacebbb94019def022f70397f74c44775) * [feat: use "page // medley" format for title](https://github.com/SayaAndy/saya-today-web/pull/40/commits/0dbb85f25c69b5e7929bb832e7967a709a76ff5c) * feat: multitone backgrounds implementation * feat: change font to m-plus for short description * fix: theme wheel position on different dpi screens in global map * feat: integrate package minor updates * refactor: convert color vars into oklch * [refactor: rm scanning by listing for s3 client](https://github.com/SayaAndy/saya-today-web/commit/1a95e20cc4e050244a76a3ea4cccc5ab30ff5a91) * fix: on errors with blog client init write correct type
Diffstat (limited to 'internal/mailer')
-rw-r--r--internal/mailer/mailer.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/internal/mailer/mailer.go b/internal/mailer/mailer.go
index ffa7b30..33db4f7 100644
--- a/internal/mailer/mailer.go
+++ b/internal/mailer/mailer.go
@@ -16,7 +16,7 @@ import (
"github.com/SayaAndy/saya-today-web/internal/blog"
"github.com/SayaAndy/saya-today-web/internal/templatemanager"
- "github.com/SayaAndy/saya-today-web/locale"
+ "github.com/SayaAndy/saya-today-web/l10n"
"github.com/dgraph-io/ristretto/v2"
"github.com/gofiber/fiber/v2"
"github.com/wneessen/go-mail"
@@ -43,8 +43,6 @@ type Mailer struct {
hashMap map[string][]byte
hashMapMutex sync.RWMutex
-
- l map[string]*locale.LocaleConfig
}
type SubscriptionType int
@@ -55,7 +53,7 @@ const (
Specific
)
-func NewMailer(db *sql.DB, clientHost string, mailHost string, publicName string, mailAddress string, username string, password string, salt []byte, localization map[string]*locale.LocaleConfig) (*Mailer, error) {
+func NewMailer(db *sql.DB, clientHost string, mailHost string, publicName string, mailAddress string, username string, password string, salt []byte) (*Mailer, error) {
verificationCodes, err := ristretto.NewCache(&ristretto.Config[uint64, string]{
NumCounters: 10000,
MaxCost: 1 << 20, // 1 MB
@@ -111,7 +109,7 @@ func NewMailer(db *sql.DB, clientHost string, mailHost string, publicName string
End time.Time
CodeExpiry time.Time
}, 0),
- l: localization}, nil
+ }, nil
}
func (m *Mailer) GetHash(id string) []byte {
@@ -261,10 +259,9 @@ func (m *Mailer) SendVerificationCode(userId string, address string, lang string
verificationInfo := fmt.Sprintf("%s.%s", base64.RawStdEncoding.EncodeToString([]byte(userId)), base64.RawStdEncoding.EncodeToString([]byte(address)))
m.verificationCodes.Set(verificationCode, verificationInfo, int64(len(verificationInfo)+8))
- message.Subject(m.l[lang].Mail.VerifyEmail.Subject)
+ message.Subject(l10n.T.GetPath(lang, "Mail", "VerifyEmail", "Subject").(string))
msg, err := m.tm.Render("verify-email", fiber.Map{
- "L": m.l[lang],
"Lang": lang,
"VerificationCode": fmt.Sprintf("%X", verificationCode),
"ClientHost": m.clientHost,
@@ -499,11 +496,10 @@ rowLoop:
rand.Read(unsubscribeCodeBytes)
unsubscribeCode := binary.LittleEndian.Uint64(unsubscribeCodeBytes)
- unsubscribeFooter := strings.Replace(m.l[post.Lang].Mail.UnsubscribeFooter, "{}", fmt.Sprintf(`<a style="color: #273de1 !important;" href="https://%s/%s/user/unsubscribe?code=%X">`, m.clientHost, post.Lang, unsubscribeCode), 1)
+ unsubscribeFooter := strings.Replace(l10n.T.GetPath(post.Lang, "Mail", "UnsubscribeFooter").(string), "{}", fmt.Sprintf(`<a style="color: #273de1 !important;" href="https://%s/%s/user/unsubscribe?code=%X">`, m.clientHost, post.Lang, unsubscribeCode), 1)
unsubscribeFooter = strings.Replace(unsubscribeFooter, "{/}", "</a>", 1)
msgBody, err := m.tm.Render("new-post", fiber.Map{
- "L": m.l[post.Lang],
"Lang": post.Lang,
"Post": post,
"ClientHost": m.clientHost,
@@ -529,7 +525,7 @@ rowLoop:
message.SetMessageID()
message.SetDate()
message.SetBulk()
- message.Subject(m.l[post.Lang].Mail.NewPost.Subject)
+ message.Subject(l10n.T.GetPath(post.Lang, "Mail", "NewPost", "Subject").(string))
message.SetBodyString(mail.TypeTextHTML, string(msgBody))
m.unsubscribeCodes.Set(unsubscribeCode, user.userId, 40)