Files
pages/internal/server/extension_state.go
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

44 lines
1.1 KiB
Go

package server
import (
"encoding/json"
"strings"
systemext "pageswiki/internal/extensions"
)
const systemExtensionStateKey = "system_extension_states"
func (s *Server) systemExtensionEnabled(domainUUID, id string) bool {
raw, err := s.store.GetConfigInDomain(domainUUID, systemExtensionStateKey)
if err != nil || strings.TrimSpace(raw) == "" {
return true
}
var states map[string]bool
if json.Unmarshal([]byte(raw), &states) != nil {
return true
}
enabled, ok := states[id]
return !ok || enabled
}
func (s *Server) setSystemExtensionEnabled(domainUUID, id string, enabled bool) error {
raw, _ := s.store.GetConfigInDomain(domainUUID, systemExtensionStateKey)
states := map[string]bool{}
_ = json.Unmarshal([]byte(raw), &states)
states[id] = enabled
payload, err := json.Marshal(states)
if err != nil {
return err
}
return s.store.SetConfigInDomain(domainUUID, systemExtensionStateKey, string(payload))
}
func (s *Server) systemExtensionCatalog(domainUUID string) []systemext.Manifest {
items := systemext.Catalog()
for i := range items {
items[i].Enabled = s.systemExtensionEnabled(domainUUID, items[i].ID)
}
return items
}