保存三数据库日志与三十天清理实现,继续补充验收
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-08 22:30:50 +08:00
1 parent 9bdf866a87
commit 5faadcd6eb
41 files changed
+1994 -59

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// Package logpolicy 统一三类日志的滚动保留期限。
package logpolicy
import "time"
const (
Retention = 30 * 24 * time.Hour
CompressionAge = 7 * 24 * time.Hour
MaintenanceInterval = time.Hour
DeleteBatchSize = 1000
)
// Cutoff 使用绝对时长,避免月份长度、时区或夏令时改变保留期。
func Cutoff(now time.Time) time.Time {
return now.UTC().Add(-Retention)
}
+13 -1
View File
@@ -7,6 +7,7 @@ import (
"git.pcux.cn/xuans/Smail/config"
"git.pcux.cn/xuans/Smail/dto/parsemail"
"git.pcux.cn/xuans/Smail/models"
"git.pcux.cn/xuans/Smail/services/logstore"
"git.pcux.cn/xuans/Smail/utils/array"
"git.pcux.cn/xuans/Smail/utils/async"
"git.pcux.cn/xuans/Smail/utils/consts"
@@ -119,7 +120,18 @@ func parseRecipientAddress(user *parsemail.User) (string, string, error) {
return address, domain, nil
}
func doSend(ctx *context.Context, fromDomain string, data []byte, to []*parsemail.User, from string) (error, map[string]error) {
func doSend(ctx *context.Context, fromDomain string, data []byte, to []*parsemail.User, from string) (sendErr error, recipientErrors map[string]error) {
defer func() {
result := "success"
if sendErr != nil || len(recipientErrors) > 0 {
result = "failure"
}
userID := 0
if ctx != nil {
userID = ctx.UserID
}
logstore.MailResult(userID, "outbound", from, len(to), len(data), result)
}()
if len(to) == 0 {
err := errors.New("no recipients")
return err, map[string]error{"recipients": err}