fixed change avatar failure error

pull/73/head
alimy 3 years ago
parent 70c52c1e9c
commit bbedb3a488

@ -6,9 +6,11 @@ import (
)
var (
objectStorage core.ObjectStorageService
objectStorage core.ObjectStorageService
attachmentChecker core.AttachmentCheckService
)
func Initialize() {
objectStorage = dao.NewObjectStorageService()
attachmentChecker = dao.NewAttachmentCheckerService()
}

@ -3,7 +3,6 @@ package api
import (
"fmt"
"net/http"
"strings"
"unicode/utf8"
"github.com/gin-gonic/gin"
@ -204,7 +203,7 @@ func ChangeAvatar(c *gin.Context) {
user = u.(*model.User)
}
if strings.Index(param.Avatar, "https://"+global.AliOSSSetting.Domain) != 0 {
if err := attachmentChecker.Check(param.Avatar); err != nil {
response.ToErrorResponse(errcode.InvalidParams)
return
}

Loading…
Cancel
Save