Compare commits
No commits in common. "1c5eca8f7249888adf9209442f826f0d35382d8f" and "b48a610e9063c2a1ba6f3615f75113e6e036e604" have entirely different histories.
1c5eca8f72
...
b48a610e90
3 changed files with 8 additions and 31 deletions
1
api.md
1
api.md
|
@ -9,5 +9,4 @@
|
||||||
| POST | /api/upload | Upload file | Upload key |
|
| POST | /api/upload | Upload file | Upload key |
|
||||||
| DELETE | /api/:id | Delete file | Upload key |
|
| DELETE | /api/:id | Delete file | Upload key |
|
||||||
| GET | /api/:id | Get file | Upload key |
|
| GET | /api/:id | Get file | Upload key |
|
||||||
| GET | /api/:id/meta | Get file metadata | None |
|
|
||||||
| GET | /api/list | Get a list of uploaded files | Session key |
|
| GET | /api/list | Get a list of uploaded files | Session key |
|
||||||
|
|
|
@ -176,30 +176,6 @@ func RegisterFileRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
|
||||||
c.DataFromReader(200, file.Size, file.Mime, object, nil)
|
c.DataFromReader(200, file.Size, file.Mime, object, nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
api.GET("/:id/meta", func(c *gin.Context) {
|
|
||||||
fileID := c.Param("id")
|
|
||||||
fileID = strings.TrimSpace(fileID)
|
|
||||||
|
|
||||||
var file *types.File
|
|
||||||
id, err := uuid.FromString(fileID)
|
|
||||||
if err != nil {
|
|
||||||
types.ErrorInvalidFile.Throw(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := cfg.Database.First(&file, id).Error; err != nil {
|
|
||||||
types.ErrorFileNotFound.Throw(c, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if file == nil {
|
|
||||||
types.ErrorFileNotFound.Throw(c, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(200, file)
|
|
||||||
})
|
|
||||||
|
|
||||||
api.GET("/list", session.SessionMiddleware(cfg.JWTSecret), func(c *gin.Context) {
|
api.GET("/list", session.SessionMiddleware(cfg.JWTSecret), func(c *gin.Context) {
|
||||||
claims := c.MustGet("claims").(jwt.MapClaims)
|
claims := c.MustGet("claims").(jwt.MapClaims)
|
||||||
user := claims["user"].(auth.User)
|
user := claims["user"].(auth.User)
|
||||||
|
|
|
@ -32,12 +32,14 @@ type TokenResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID string `json:"id" gorm:"primaryKey"`
|
ID string `json:"id" gorm:"primaryKey"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Blacklisted bool `json:"blacklisted"`
|
Blacklisted bool `json:"blacklisted"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
HashedApiKey string `json:"hashed_api_key"`
|
HashedApiKey string `json:"hashed_api_key"`
|
||||||
|
Role string `json:"role" gorm:"default:'free'"` // free, pro, pro+, admin
|
||||||
|
SubscriptionExpiresAt time.Time `json:"subscription_expires_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AvatarDecorationData struct {
|
type AvatarDecorationData struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue