feat(upload): 接入媒体策略与日志选项

为上传服务注入 media.Policy 与 zap.Logger,对齐广场媒体校验。
This commit is contained in:
DESKTOP-L8OUL9F\gfl0034 2026-09-24 23:07:21 +08:00
parent 715ace7ac6
commit f708a86d5c

View File

@ -5,7 +5,10 @@ import (
"strconv"
"time"
"spark-server/internal/pkg/media"
"spark-server/internal/pkg/ratelimit"
"go.uber.org/zap"
)
// Presigner issues short-lived object-storage URLs. Infrastructure implements it.
@ -23,6 +26,8 @@ type Options struct {
Limit *ratelimit.Limiter
Now func() time.Time
Groups AvatarACL
Media media.Policy
Log *zap.Logger
}
// Service issues upload/download credentials. HTTP and TCP share it.
@ -32,6 +37,8 @@ type Service struct {
limit *ratelimit.Limiter
now func() time.Time
groups AvatarACL
media media.Policy
log *zap.Logger
}
func NewService(store Presigner, opt Options) *Service {
@ -43,7 +50,11 @@ func NewService(store Presigner, opt Options) *Service {
if clock == nil {
clock = func() time.Time { return time.Now().UTC() }
}
return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups}
log := opt.Log
if log == nil {
log = zap.NewNop()
}
return &Service{store: store, ttl: ttl, limit: opt.Limit, now: clock, groups: opt.Groups, media: opt.Media, log: log}
}
func (s *Service) ready() bool {