Compare commits
3 Commits
bb26cfca5b
...
1dd4fa22cd
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | 1dd4fa22cd | |
Derrick Hammer | 30ad92fb8d | |
Derrick Hammer | ce1b5e31d5 |
|
@ -3,6 +3,7 @@ package controller
|
|||
import (
|
||||
"git.lumeweb.com/LumeWeb/portal/controller/request"
|
||||
"git.lumeweb.com/LumeWeb/portal/controller/response"
|
||||
"git.lumeweb.com/LumeWeb/portal/middleware"
|
||||
"git.lumeweb.com/LumeWeb/portal/service/auth"
|
||||
"github.com/kataras/iris/v12"
|
||||
)
|
||||
|
@ -99,3 +100,13 @@ func (a *AuthController) PostLogout() {
|
|||
// Return a success response to the client.
|
||||
a.Ctx.StatusCode(iris.StatusNoContent)
|
||||
}
|
||||
|
||||
func (a *AuthController) GetStatus() {
|
||||
middleware.VerifyJwt(a.Ctx)
|
||||
|
||||
if a.Ctx.IsStopped() {
|
||||
return
|
||||
}
|
||||
|
||||
a.respondJSON(&response.AuthStatusResponse{Status: true})
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ func (f *FilesController) GetStatusBy(cidString string) {
|
|||
break
|
||||
}
|
||||
|
||||
f.respondJSON(&response.StatusResponse{Status: statusCode})
|
||||
f.respondJSON(&response.FileStatusResponse{Status: statusCode})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package response
|
||||
|
||||
type AuthStatusResponse struct {
|
||||
Status bool `json:"status"`
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package response
|
||||
|
||||
type StatusResponse struct {
|
||||
type FileStatusResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
|
@ -80,17 +80,14 @@ func Upload(r io.ReadSeeker, size int64, hash []byte) (model.Upload, error) {
|
|||
}
|
||||
|
||||
result := db.Get().Where(&model.Upload{Hash: hashHex}).First(&upload)
|
||||
if (result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound)) || result.RowsAffected > 0 {
|
||||
err := result.Row().Scan(&upload)
|
||||
if !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
if err != nil {
|
||||
logger.Get().Error(ErrFailedQueryUpload.Error(), zap.Error(err))
|
||||
return upload, ErrFailedQueryUpload
|
||||
}
|
||||
|
||||
if result.RowsAffected > 0 && upload.ID > 0 {
|
||||
logger.Get().Info(ErrAlreadyExists.Error())
|
||||
return upload, nil
|
||||
}
|
||||
logger.Get().Info(ErrAlreadyExists.Error())
|
||||
return upload, nil
|
||||
}
|
||||
|
||||
objectExistsResult, err := client.R().Get(getBusObjectUrl(hashHex))
|
||||
|
|
Loading…
Reference in New Issue