From ec1833dbebc69f26b91e5ee2c761522e3ad0494a Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 20 Apr 2026 18:56:41 +0200 Subject: [PATCH] feat(license): expose enabled_pro_features on /info --- pkg/license/license.go | 21 +++++++++++++++++++++ pkg/routes/api/v1/info.go | 3 +++ 2 files changed, 24 insertions(+) diff --git a/pkg/license/license.go b/pkg/license/license.go index 1422d9f3c..59f95748a 100644 --- a/pkg/license/license.go +++ b/pkg/license/license.go @@ -35,6 +35,7 @@ package license import ( "encoding/json" "fmt" + "sort" "sync" "time" @@ -192,6 +193,26 @@ func Init() { go backgroundLoop(key) } +// EnabledProFeatures returns the string keys of all currently enabled licensed features. +// Returns an empty slice in free mode. +func EnabledProFeatures() []string { + currentState.mu.RLock() + defer currentState.mu.RUnlock() + if !currentState.licensed { + return []string{} + } + out := make([]string, 0, len(currentState.features)) + for f, on := range currentState.features { + if !on { + continue + } + name := f.String() + out = append(out, name) + } + sort.Strings(out) + return out +} + // IsFeatureEnabled returns whether a specific licensed feature is enabled. func IsFeatureEnabled(feature Feature) bool { currentState.mu.RLock() diff --git a/pkg/routes/api/v1/info.go b/pkg/routes/api/v1/info.go index ed429f48a..ec2eb4f8e 100644 --- a/pkg/routes/api/v1/info.go +++ b/pkg/routes/api/v1/info.go @@ -20,6 +20,7 @@ import ( "net/http" "code.vikunja.io/api/pkg/config" + "code.vikunja.io/api/pkg/license" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/modules/auth/openid" csvmigrator "code.vikunja.io/api/pkg/modules/migration/csv" @@ -54,6 +55,7 @@ type vikunjaInfos struct { DemoModeEnabled bool `json:"demo_mode_enabled"` WebhooksEnabled bool `json:"webhooks_enabled"` PublicTeamsEnabled bool `json:"public_teams_enabled"` + EnabledProFeatures []string `json:"enabled_pro_features"` } type authInfo struct { @@ -105,6 +107,7 @@ func Info(c *echo.Context) error { DemoModeEnabled: config.ServiceDemoMode.GetBool(), WebhooksEnabled: config.WebhooksEnabled.GetBool(), PublicTeamsEnabled: config.ServiceEnablePublicTeams.GetBool(), + EnabledProFeatures: license.EnabledProFeatures(), AvailableMigrators: []string{ (&vikunja_file.FileMigrator{}).Name(), (&ticktick.Migrator{}).Name(),