Skip to content

Commit

Permalink
Add sync routes for v3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
nemunaire committed Nov 8, 2023
1 parent d94e36c commit f1827cd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
15 changes: 15 additions & 0 deletions internal/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,21 @@ func (app *App) syncGetRootV3(c *gin.Context) {
})
}

func (app *App) blobStorageRead(c *gin.Context) {
uid := c.GetString(userIDKey)
blobID := common.ParamS(fileKey, c)

reader, _, size, err := app.blobStorer.LoadBlob(uid, blobID)
if err != nil {
log.Error(err)
c.AbortWithStatus(http.StatusInternalServerError)
return
}
defer reader.Close()

c.DataFromReader(http.StatusOK, size, "application/octet-stream", reader, nil)
}

func (app *App) integrationsGetMetadata(c *gin.Context) {
var metadata messages.IntegrationMetadata
metadata.Thumbnail = ""
Expand Down
11 changes: 6 additions & 5 deletions internal/app/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
)

const (
authLog = "[auth-middleware]"
requestLog = "[requestlogging-middleware]"
syncDefault = "sync:default"
syncNew = "sync:tortoise"
authLog = "[auth-middleware]"
requestLog = "[requestlogging-middleware]"
syncDefault = "sync:default"
syncNew = "sync:tortoise"
syncNewLimited = "sync:fox" // Display cloud limit messages
)

func (app *App) authMiddleware() gin.HandlerFunc {
Expand All @@ -35,7 +36,7 @@ func (app *App) authMiddleware() gin.HandlerFunc {

var isSync15 = false
for _, s := range scopes {
if s == syncNew {
if s == syncNew || s == syncNewLimited {
isSync15 = true
break
}
Expand Down
1 change: 1 addition & 0 deletions internal/app/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ func (app *App) registerRoutes(router *gin.Engine) {

authRoutes.GET("/sync/v3/root", app.syncGetRootV3)
authRoutes.PUT("/sync/v3/root", app.syncUpdateRootV3)
authRoutes.GET("/sync/v3/files/:"+fileKey, app.blobStorageRead)
}
}

0 comments on commit f1827cd

Please sign in to comment.