diff options
author | 2024-03-25 18:32:24 +0100 | |
---|---|---|
committer | 2024-03-25 17:32:24 +0000 | |
commit | 8953f57d887c060c3b58f83c38d2010d27a45ef3 (patch) | |
tree | 05f8b1157a86afaa3ed0d6d0b87c9d0d37030362 /internal/typeutils/internaltofrontend.go | |
parent | [feature] Add healthcheck endpoints `/livez` and `/readyz` (#2783) (diff) | |
download | gotosocial-8953f57d887c060c3b58f83c38d2010d27a45ef3.tar.xz |
[feature] User-selectable preset CSS themes for accounts (#2777)
* [feature] User-selectable preset themes
* docs, more theme stuff
* lint, tests
* fix css name
* correct some little issues
* add another theme
* fix poll background
* okay last theme i swear
* make retrieval of apimodel themes more conventional
* preallocate stylesheet slices
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 0ff3c2268..bf44c7254 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -170,12 +170,13 @@ func (c *Converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A // Bits that vary between remote + local accounts: // - Account (acct) string. // - Role. - // - Settings things (enableRSS, customCSS). + // - Settings things (enableRSS, theme, customCSS). var ( acct string role *apimodel.AccountRole enableRSS bool + theme string customCSS string ) @@ -208,6 +209,7 @@ func (c *Converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A } enableRSS = *a.Settings.EnableRSS + theme = a.Settings.Theme customCSS = a.Settings.CustomCSS } @@ -272,6 +274,7 @@ func (c *Converter) AccountToAPIAccountPublic(ctx context.Context, a *gtsmodel.A Emojis: apiEmojis, Fields: fields, Suspended: !a.SuspendedAt.IsZero(), + Theme: theme, CustomCSS: customCSS, EnableRSS: enableRSS, Role: role, @@ -1771,3 +1774,16 @@ func (c *Converter) convertTagsToAPITags(ctx context.Context, tags []*gtsmodel.T return apiTags, errs.Combine() } + +// ThemesToAPIThemes converts a slice of gtsmodel Themes into apimodel Themes. +func (c *Converter) ThemesToAPIThemes(themes []*gtsmodel.Theme) []apimodel.Theme { + apiThemes := make([]apimodel.Theme, len(themes)) + for i, theme := range themes { + apiThemes[i] = apimodel.Theme{ + Title: theme.Title, + Description: theme.Description, + FileName: theme.FileName, + } + } + return apiThemes +} |