mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: download file from single file share
This commit is contained in:
@@ -46,8 +46,8 @@ const (
|
||||
CodeNotFullySuccess = 203
|
||||
// CodeCheckLogin 未登录
|
||||
CodeCheckLogin = 401
|
||||
// CodeNoRightErr 未授权访问
|
||||
CodeNoRightErr = 403
|
||||
// CodeNoPermissionErr 未授权访问
|
||||
CodeNoPermissionErr = 403
|
||||
// CodeNotFound 资源未找到
|
||||
CodeNotFound = 404
|
||||
// CodeUploadFailed 上传出错
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
// Share 分享序列化
|
||||
type Share struct {
|
||||
Key string `json:"key"`
|
||||
Locked bool `json:"locked"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
Score int `json:"score"`
|
||||
@@ -34,6 +35,7 @@ type shareSource struct {
|
||||
func BuildShareResponse(share *model.Share, unlocked bool) Share {
|
||||
creator := share.GetCreator()
|
||||
resp := Share{
|
||||
Key: hashid.HashID(share.ID, hashid.ShareID),
|
||||
Locked: !unlocked,
|
||||
Creator: &shareCreator{
|
||||
Key: hashid.HashID(creator.ID, hashid.UserID),
|
||||
|
||||
@@ -22,6 +22,7 @@ type User struct {
|
||||
Avatar string `json:"avatar"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
PreferredTheme string `json:"preferred_theme"`
|
||||
Score int `json:"score"`
|
||||
Policy policy `json:"policy"`
|
||||
Group group `json:"group"`
|
||||
}
|
||||
@@ -41,6 +42,7 @@ type group struct {
|
||||
AllowRemoteDownload bool `json:"allowRemoteDownload"`
|
||||
AllowTorrentDownload bool `json:"allowTorrentDownload"`
|
||||
AllowArchiveDownload bool `json:"allowArchiveDownload"`
|
||||
ShareFreeEnabled bool `json:"shareFree"`
|
||||
}
|
||||
|
||||
type storage struct {
|
||||
@@ -60,6 +62,7 @@ func BuildUser(user model.User) User {
|
||||
Avatar: user.Avatar,
|
||||
CreatedAt: user.CreatedAt.Unix(),
|
||||
PreferredTheme: user.OptionsSerialized.PreferredTheme,
|
||||
Score: user.Score,
|
||||
Policy: policy{
|
||||
SaveType: user.Policy.Type,
|
||||
MaxSize: fmt.Sprintf("%.2fmb", float64(user.Policy.MaxSize)/(1024*1024)),
|
||||
@@ -74,6 +77,7 @@ func BuildUser(user model.User) User {
|
||||
AllowRemoteDownload: aria2Option[0],
|
||||
AllowTorrentDownload: aria2Option[2],
|
||||
AllowArchiveDownload: user.Group.OptionsSerialized.ArchiveDownloadEnabled,
|
||||
ShareFreeEnabled: user.Group.OptionsSerialized.ShareFreeEnabled,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user