Skip to content

Commit

Permalink
New routes for v3.10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nemunaire committed Mar 20, 2024
1 parent 3c9bd50 commit d344fb4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,35 @@ func (app *App) syncGetRootV3(c *gin.Context) {
})
}

func (app *App) checkFilesPresence(c *gin.Context) {
uid := c.GetString(userIDKey)
var req messages.CheckFiles
if err := c.ShouldBindJSON(&req); err != nil {
log.Error(err)
badReq(c, err.Error())
return
}

mfs := message.MissingFiles{}

Check failure on line 791 in internal/app/handlers.go

View workflow job for this annotation

GitHub Actions / Build

undefined: message

for _, fileid := range req.Files {
_, _, err := app.blobStorer.GetBlobURL(uid, fileid, false)
if err != nil {
mfs = append(mfs, fileid)
}
}

c.JSON(http.StatusOK, mfs)
}

func (app *App) checkMissingBlob(c *gin.Context) {
mhs := message.MissingHashes{}

Check failure on line 804 in internal/app/handlers.go

View workflow job for this annotation

GitHub Actions / Build

undefined: message

// TODO

c.JSON(http.StatusOK, mhs)
}

func (app *App) blobStorageRead(c *gin.Context) {
uid := c.GetString(userIDKey)
blobID := common.ParamS(fileKey, c)
Expand Down
13 changes: 13 additions & 0 deletions internal/app/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func (app *App) registerRoutes(router *gin.Engine) {
}
c.Status(http.StatusOK)
})
router.POST("/v2/reports", func(c *gin.Context) {
_, err := ioutil.ReadAll(c.Request.Body)

if err != nil {
log.Warn("cant parse telemetry, ignored")
c.Status(http.StatusOK)
return
}
c.Status(http.StatusOK)
})

//routes needing api authentitcation
authRoutes := router.Group("/")
Expand Down Expand Up @@ -144,5 +154,8 @@ func (app *App) registerRoutes(router *gin.Engine) {
authRoutes.PUT("/sync/v3/root", app.syncUpdateRootV3)
authRoutes.GET("/sync/v3/files/:"+fileKey, app.blobStorageRead)
authRoutes.PUT("/sync/v3/files/:"+fileKey, app.blobStorageWrite)

authRoutes.POST("/sync/v3/check-files", app.checkFilesPresence)
authRoutes.GET("/sync/v3/missing", app.checkMissingBlob)
}
}
14 changes: 14 additions & 0 deletions internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ type SyncRootV3 struct {
Hash string `json:"hash,omitempty"`
}

type CheckFiles struct {
Filename string `json:"filename"`
Files []string `json:"files"`
Reason string `json:"reason"`
}

type MissingFiles struct {
MissingFiles []string `json:"missingFiles"`
}

type MissingHashes struct {
Hashes []string `json:"hashes"`
}

// IntegrationsResponse integrations
type IntegrationsResponse struct {
Integrations []Integration `json:"integrations"`
Expand Down

0 comments on commit d344fb4

Please sign in to comment.