mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-27 18:11:57 +08:00
feat(wopi): change doc preview config based on WOPI discovery results
This commit is contained in:
@@ -7,22 +7,23 @@ import (
|
||||
|
||||
// SiteConfig 站点全局设置序列
|
||||
type SiteConfig struct {
|
||||
SiteName string `json:"title"`
|
||||
LoginCaptcha bool `json:"loginCaptcha"`
|
||||
RegCaptcha bool `json:"regCaptcha"`
|
||||
ForgetCaptcha bool `json:"forgetCaptcha"`
|
||||
EmailActive bool `json:"emailActive"`
|
||||
Themes string `json:"themes"`
|
||||
DefaultTheme string `json:"defaultTheme"`
|
||||
HomepageViewMethod string `json:"home_view_method"`
|
||||
ShareViewMethod string `json:"share_view_method"`
|
||||
Authn bool `json:"authn"`
|
||||
User User `json:"user"`
|
||||
ReCaptchaKey string `json:"captcha_ReCaptchaKey"`
|
||||
CaptchaType string `json:"captcha_type"`
|
||||
TCaptchaCaptchaAppId string `json:"tcaptcha_captcha_app_id"`
|
||||
RegisterEnabled bool `json:"registerEnabled"`
|
||||
AppPromotion bool `json:"app_promotion"`
|
||||
SiteName string `json:"title"`
|
||||
LoginCaptcha bool `json:"loginCaptcha"`
|
||||
RegCaptcha bool `json:"regCaptcha"`
|
||||
ForgetCaptcha bool `json:"forgetCaptcha"`
|
||||
EmailActive bool `json:"emailActive"`
|
||||
Themes string `json:"themes"`
|
||||
DefaultTheme string `json:"defaultTheme"`
|
||||
HomepageViewMethod string `json:"home_view_method"`
|
||||
ShareViewMethod string `json:"share_view_method"`
|
||||
Authn bool `json:"authn"`
|
||||
User User `json:"user"`
|
||||
ReCaptchaKey string `json:"captcha_ReCaptchaKey"`
|
||||
CaptchaType string `json:"captcha_type"`
|
||||
TCaptchaCaptchaAppId string `json:"tcaptcha_captcha_app_id"`
|
||||
RegisterEnabled bool `json:"registerEnabled"`
|
||||
AppPromotion bool `json:"app_promotion"`
|
||||
WopiExts []string `json:"wopi_exts"`
|
||||
}
|
||||
|
||||
type task struct {
|
||||
@@ -60,7 +61,7 @@ func checkSettingValue(setting map[string]string, key string) string {
|
||||
}
|
||||
|
||||
// BuildSiteConfig 站点全局设置
|
||||
func BuildSiteConfig(settings map[string]string, user *model.User) Response {
|
||||
func BuildSiteConfig(settings map[string]string, user *model.User, wopiExts []string) Response {
|
||||
var userRes User
|
||||
if user != nil {
|
||||
userRes = BuildUser(*user)
|
||||
@@ -85,6 +86,7 @@ func BuildSiteConfig(settings map[string]string, user *model.User) Response {
|
||||
TCaptchaCaptchaAppId: checkSettingValue(settings, "captcha_TCaptcha_CaptchaAppId"),
|
||||
RegisterEnabled: model.IsTrueVal(checkSettingValue(settings, "register_enabled")),
|
||||
AppPromotion: model.IsTrueVal(checkSettingValue(settings, "show_app_promotion")),
|
||||
WopiExts: wopiExts,
|
||||
}}
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ func TestCheckSettingValue(t *testing.T) {
|
||||
func TestBuildSiteConfig(t *testing.T) {
|
||||
asserts := assert.New(t)
|
||||
|
||||
res := BuildSiteConfig(map[string]string{"not exist": ""}, &model.User{})
|
||||
res := BuildSiteConfig(map[string]string{"not exist": ""}, &model.User{}, nil)
|
||||
asserts.Equal("", res.Data.(SiteConfig).SiteName)
|
||||
|
||||
res = BuildSiteConfig(map[string]string{"siteName": "123"}, &model.User{})
|
||||
res = BuildSiteConfig(map[string]string{"siteName": "123"}, &model.User{}, nil)
|
||||
asserts.Equal("123", res.Data.(SiteConfig).SiteName)
|
||||
|
||||
// 非空用户
|
||||
@@ -29,7 +29,7 @@ func TestBuildSiteConfig(t *testing.T) {
|
||||
Model: gorm.Model{
|
||||
ID: 5,
|
||||
},
|
||||
})
|
||||
}, nil)
|
||||
asserts.Len(res.Data.(SiteConfig).User.ID, 4)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user