Feat: re-save shared folder to user's space

This commit is contained in:
HFO4
2020-01-31 11:27:52 +08:00
parent b1a9943b0c
commit f5d79b1f94
10 changed files with 51 additions and 60 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/HFO4/cloudreve/pkg/util"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
"math"
"time"
)
@@ -170,7 +171,7 @@ func (share *Share) DownloadBy(user *User, c *gin.Context) error {
// Purchase 使用积分购买分享
func (share *Share) Purchase(user *User) error {
// 不需要付积分
if share.Score == 0 || user.Group.OptionsSerialized.ShareFreeEnabled {
if share.Score == 0 || user.Group.OptionsSerialized.ShareFreeEnabled || user.ID == share.UserID {
return nil
}
@@ -179,6 +180,10 @@ func (share *Share) Purchase(user *User) error {
return errors.New("积分不足")
}
scoreRate := GetIntSetting("share_score_rate", 100)
gainedScore := int(math.Ceil(float64(share.Score*scoreRate) / 100))
share.GetCreator().AddScore(gainedScore)
return nil
}