diff --git a/internal/module/upload/logic/service.go b/internal/module/upload/logic/service.go index 6c86b65..9196283 100644 --- a/internal/module/upload/logic/service.go +++ b/internal/module/upload/logic/service.go @@ -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 {