This commit is contained in:
ponzischeme89
2026-08-22 18:40:50 +12:00
parent 9858e44710
commit 7d77700c7b
36 changed files with 480 additions and 119 deletions
+1
View File
@@ -62,6 +62,7 @@ var configurationCatalogue = []configurationDefinition{
{Key: "continueWatching.enabled", Name: "Continue Watching", Description: "Show the Continue Watching row.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "continueWatching.showNextUp", Name: "Continue Watching: Next Up", Description: "Include an unstarted next episode in Continue Watching.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "continueWatching.progressColour", Name: "Progress bar colour", Description: "Choose the progress bar treatment.", Type: "enum", Scopes: []string{"global", "user", "device"}, Default: "emby", Options: []string{"emby", "white"}},
{Key: "presentation.fontFamily", Name: "App font family", Description: "Choose the bundled font used in Membys typography trial areas.", Type: "enum", Scopes: []string{"global"}, Default: "system", Options: []string{"system", "inter"}},
{Key: "ratings.enabled", Name: "Ratings", Description: "Show ratings throughout the catalogue.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "genres.enabled", Name: "Genres", Description: "Show genre browsing controls.", Type: "boolean", Scopes: []string{"global", "user", "device"}, Default: true},
{Key: "trailers.enabled", Name: "Trailers", Description: "Offer trailers where available.", Type: "boolean", Scopes: []string{"global", "device", "experimental"}, Default: true},
+14
View File
@@ -1,6 +1,7 @@
package api
import (
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
@@ -75,6 +76,19 @@ func TestContinueWatchingIsServerControlledAndOnByDefault(t *testing.T) {
}
}
func TestAppFontFamilyIsAValidatedGlobalConfiguration(t *testing.T) {
definition, ok := configurationDefinitionFor("presentation.fontFamily")
if !ok || definition.Type != "enum" || len(definition.Scopes) != 1 || definition.Scopes[0] != "global" {
t.Fatalf("font family definition = %+v, found=%v", definition, ok)
}
if err := validateConfigurationValue(definition, json.RawMessage(`"inter"`)); err != nil {
t.Fatalf("Inter was rejected: %v", err)
}
if err := validateConfigurationValue(definition, json.RawMessage(`"unknown"`)); err == nil {
t.Fatal("unknown font family was accepted")
}
}
func TestClientCapabilitiesAreNormalizedAndBounded(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/v1/status", nil)
req.Header.Set("X-Memby-Capabilities", " Sonarr_Preroll_V1,server_features_v1,sonarr_preroll_v1,"+
+4
View File
@@ -107,6 +107,10 @@ func applyGlobalConfiguration(document *config.RemoteConfig, policy store.Featur
if v, ok := value.(string); ok {
document.ContinueWatching.ProgressColour = v
}
case "presentation.fontFamily":
if v, ok := value.(string); ok && (v == "system" || v == "inter") {
document.Presentation.FontFamily = v
}
case "home.heroRefreshSeconds":
if v, ok := value.(float64); ok {
document.Home.HeroRefreshSeconds = int(v)
+14
View File
@@ -1,11 +1,13 @@
package api
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/ponzischeme89/memby/server/internal/config"
"github.com/ponzischeme89/memby/server/internal/store"
)
func TestRemoteConfigSupportsETagRevalidationWithoutAuthentication(t *testing.T) {
@@ -31,3 +33,15 @@ func TestRemoteConfigSupportsETagRevalidationWithoutAuthentication(t *testing.T)
t.Fatalf("revalidation status = %d", second.Code)
}
}
func TestGlobalFontFamilyConfigurationIsDelivered(t *testing.T) {
document := config.DefaultRemoteConfig()
policy := store.DefaultFeaturePolicy()
policy.Values["presentation.fontFamily"] = json.RawMessage(`"inter"`)
applyGlobalConfiguration(&document, policy)
if document.Presentation.FontFamily != "inter" {
t.Fatalf("font family = %q, want inter", document.Presentation.FontFamily)
}
}
+7 -2
View File
@@ -56,8 +56,9 @@ type RemoteConfigFeatures struct {
}
type RemoteConfigPresentation struct {
NavigationRailExpandedWidthDp int `json:"navigationRailExpandedWidthDp"`
NavigationContentShiftDp int `json:"navigationContentShiftDp"`
NavigationRailExpandedWidthDp int `json:"navigationRailExpandedWidthDp"`
NavigationContentShiftDp int `json:"navigationContentShiftDp"`
FontFamily string `json:"fontFamily"`
}
// The remainder of the document is deliberately declarative. A new server-side row or
@@ -160,6 +161,7 @@ func DefaultRemoteConfig() RemoteConfig {
Presentation: RemoteConfigPresentation{
NavigationRailExpandedWidthDp: 184,
NavigationContentShiftDp: 112,
FontFamily: "system",
},
Home: RemoteHomeConfig{
Sections: []string{"continue", "for-you", "favorites", "latest-movies"},
@@ -262,6 +264,9 @@ func validateRemoteConfig(document RemoteConfig) error {
if shift < 80 || shift > 160 || shift >= width {
return fmt.Errorf("navigationContentShiftDp must be between 80 and 160 and less than the rail width")
}
if document.Presentation.FontFamily != "system" && document.Presentation.FontFamily != "inter" {
return fmt.Errorf("fontFamily must be system or inter")
}
if err := validateRemoteConfigSections(document); err != nil {
return err
}
@@ -19,6 +19,9 @@ func TestRemoteConfigDefaultsAreComplete(t *testing.T) {
if !document.ContinueWatching.IncludeNextUp || len(document.Home.Sections) == 0 {
t.Fatalf("central defaults are incomplete: %+v", document)
}
if document.Presentation.FontFamily != "system" {
t.Fatalf("font family = %q, want system", document.Presentation.FontFamily)
}
}
func TestRemoteConfigDefaultsMissingNewSectionsForOlderDocuments(t *testing.T) {
@@ -47,6 +50,16 @@ func TestRemoteConfigRejectsMalformedAndUnsafeDocuments(t *testing.T) {
t.Fatal("unknown fields were accepted")
}
document = DefaultRemoteConfig()
document.Presentation.FontFamily = "comic-sans"
raw, err = json.Marshal(document)
if err != nil {
t.Fatal(err)
}
if _, err := loadRemoteConfig(string(raw)); err == nil {
t.Fatal("unknown font family was accepted")
}
document = DefaultRemoteConfig()
document.MinimumAppVersion = "0.3.0"
document.MaximumAppVersion = "0.2.54"