Skip to content

🎧 Your Personal Streaming Service

feat(server): add DefaultShareExpiration config option (#4082)

Caio Cottsfef1739c1a5e
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]