From fef1739c1a5ed094f409d8e0303ce98a89e3495e Mon Sep 17 00:00:00 2001 From: Caio Cotts Date: Tue, 20 May 2025 22:17:30 -0400 Subject: [PATCH] feat(server): add DefaultShareExpiration config option (#4082) * add DefaultShareExpiration config option * run prettier so that I can push * undo reformatting * sort imports --- conf/configuration.go | 2 ++ core/share.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/configuration.go b/conf/configuration.go index 1223ffedf..eebf1c004 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -72,6 +72,7 @@ type configOptions struct { EnableUserEditing bool EnableSharing bool ShareURL string + DefaultShareExpiration time.Duration DefaultDownloadableShare bool DefaultTheme string DefaultLanguage string @@ -472,6 +473,7 @@ func init() { viper.SetDefault("enablecoveranimation", true) viper.SetDefault("enablesharing", false) viper.SetDefault("shareurl", "") + viper.SetDefault("defaultshareexpiration", 8760*time.Hour) viper.SetDefault("defaultdownloadableshare", false) viper.SetDefault("gatrackingid", "") viper.SetDefault("enableinsightscollector", true) diff --git a/core/share.go b/core/share.go index e6035ab82..add88322d 100644 --- a/core/share.go +++ b/core/share.go @@ -8,6 +8,7 @@ import ( "github.com/Masterminds/squirrel" "github.com/deluan/rest" gonanoid "github.com/matoous/go-nanoid/v2" + "github.com/navidrome/navidrome/conf" "github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/model" . "github.com/navidrome/navidrome/utils/gg" @@ -93,7 +94,7 @@ func (r *shareRepositoryWrapper) Save(entity interface{}) (string, error) { } s.ID = id if V(s.ExpiresAt).IsZero() { - s.ExpiresAt = P(time.Now().Add(365 * 24 * time.Hour)) + s.ExpiresAt = P(time.Now().Add(conf.Server.DefaultShareExpiration)) } firstId := strings.SplitN(s.ResourceIDs, ",", 2)[0]