mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Modify: parameters in headers should be URIEncoded
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package serializer
|
||||
|
||||
import (
|
||||
model "github.com/HFO4/cloudreve/models"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
@@ -23,4 +25,13 @@ func TestBuildSiteConfig(t *testing.T) {
|
||||
|
||||
res = BuildSiteConfig(map[string]string{"qq_login": "1"}, nil)
|
||||
asserts.Equal(true, res.Data.(SiteConfig).QQLogin)
|
||||
asserts.Equal(uint(0), res.Data.(SiteConfig).User.ID)
|
||||
|
||||
// 非空用户
|
||||
res = BuildSiteConfig(map[string]string{"qq_login": "1"}, &model.User{
|
||||
Model: gorm.Model{
|
||||
ID: 5,
|
||||
},
|
||||
})
|
||||
asserts.Equal(uint(5), res.Data.(SiteConfig).User.ID)
|
||||
}
|
||||
|
||||
@@ -22,8 +22,21 @@ type User struct {
|
||||
Avatar string `json:"avatar"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
PreferredTheme string `json:"preferred_theme"`
|
||||
Policy struct {
|
||||
} `json:"policy"`
|
||||
Policy Policy `json:"policy"`
|
||||
Group Group `json:"group"`
|
||||
}
|
||||
|
||||
type Policy struct {
|
||||
SaveType string `json:"saveType"`
|
||||
MaxSize string `json:"maxSize"`
|
||||
AllowedType []string `json:"allowedType"`
|
||||
UploadURL string `json:"upUrl"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
AllowShare bool `json:"allowShare"`
|
||||
AllowRemoteDownload bool `json:"allowRemoteDownload"`
|
||||
AllowTorrentDownload bool `json:"allowTorrentDownload"`
|
||||
}
|
||||
|
||||
// BuildUser 序列化用户
|
||||
@@ -37,6 +50,17 @@ func BuildUser(user model.User) User {
|
||||
Avatar: user.Avatar,
|
||||
CreatedAt: user.CreatedAt.Unix(),
|
||||
PreferredTheme: user.OptionsSerialized.PreferredTheme,
|
||||
Policy: Policy{
|
||||
SaveType: user.Policy.Type,
|
||||
MaxSize: fmt.Sprintf("%.2fmb", float64(user.Policy.MaxSize)/1024*1024),
|
||||
AllowedType: user.Policy.OptionsSerialized.FileType,
|
||||
UploadURL: user.Policy.Server,
|
||||
},
|
||||
Group: Group{
|
||||
AllowShare: user.Group.ShareEnabled,
|
||||
AllowRemoteDownload: user.Group.Aria2Option[0] == '1',
|
||||
AllowTorrentDownload: user.Group.Aria2Option[2] == '1',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user