feat(license): expose enabled_pro_features on /info

This commit is contained in:
kolaente 2026-04-20 18:56:41 +02:00 committed by kolaente
parent d208629909
commit ec1833dbeb
2 changed files with 24 additions and 0 deletions

View File

@ -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()

View File

@ -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(),