diff options
author | Joe Chen <jc@unknwon.io> | 2022-10-22 20:01:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-22 20:01:38 +0800 |
commit | ce25881c880d9711f211be05f92a809304a436e3 (patch) | |
tree | 9239c155c8276761de6639fd19b0a56e87eedde5 /internal/conf | |
parent | 7cbd84d5b3d4af36e4afcf7af9374bc765f6bb9c (diff) |
refactor(db): move some methods off `user.go` (#7199)
Diffstat (limited to 'internal/conf')
-rw-r--r-- | internal/conf/mocks.go | 8 | ||||
-rw-r--r-- | internal/conf/static.go | 40 |
2 files changed, 30 insertions, 18 deletions
diff --git a/internal/conf/mocks.go b/internal/conf/mocks.go index af5b1bd7..2c10c1ce 100644 --- a/internal/conf/mocks.go +++ b/internal/conf/mocks.go @@ -55,3 +55,11 @@ func SetMockUI(t *testing.T, opts UIOpts) { UI = before }) } + +func SetMockPicture(t *testing.T, opts PictureOpts) { + before := Picture + Picture = opts + t.Cleanup(func() { + Picture = before + }) +} diff --git a/internal/conf/static.go b/internal/conf/static.go index 8132547f..a514f7a6 100644 --- a/internal/conf/static.go +++ b/internal/conf/static.go @@ -12,12 +12,6 @@ import ( "github.com/gogs/go-libravatar" ) -const ( - // UsersAvatarURLPath is used to identify whether a URL is to access user - // avatars. - UsersAvatarURLPath = "avatars" -) - // ℹ️ README: This file contains static values that should only be set at initialization time. // // ⚠️ WARNING: After changing any options, do not forget to update template of @@ -132,18 +126,6 @@ var ( FormatLayout string `ini:"-"` // Actual layout of the Format. } - // Picture settings - Picture struct { - AvatarUploadPath string - RepositoryAvatarUploadPath string - GravatarSource string - DisableGravatar bool - EnableFederatedAvatar bool - - // Derived from other static values - LibravatarService *libravatar.Libravatar `ini:"-"` // Initialized client for federated avatar. - } - // Mirror settings Mirror struct { DefaultInterval int @@ -408,6 +390,20 @@ type UIOpts struct { // UI settings var UI UIOpts +type PictureOpts struct { + AvatarUploadPath string + RepositoryAvatarUploadPath string + GravatarSource string + DisableGravatar bool + EnableFederatedAvatar bool + + // Derived from other static values + LibravatarService *libravatar.Libravatar `ini:"-"` // Initialized client for federated avatar. +} + +// Picture settings +var Picture PictureOpts + type i18nConf struct { Langs []string `delim:","` Names []string `delim:","` @@ -448,3 +444,11 @@ var ( UsePostgreSQL bool UseMSSQL bool ) + +// UsersAvatarPathPrefix is the path prefix to user avatars. +const UsersAvatarPathPrefix = "avatars" + +// UserDefaultAvatarURLPath returns the URL path of the default user avatar. +func UserDefaultAvatarURLPath() string { + return Server.Subpath + "/img/avatar_default.png" +} |