Skip to content

Commit

Permalink
Merge pull request #297 from nemunaire/f/v3.10
Browse files Browse the repository at this point in the history
New routes for v3.10 compatibility
  • Loading branch information
nemunaire authored Mar 20, 2024
2 parents d73a249 + f6c8dfd commit 783da33
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a replacement of the cloud, in case you want to sync/backup your files a
## [Docs](https://ddvk.github.io/rmfakecloud/)

## NB
The current release of rmfakecloud support file synchronization for SW <= 3.9.3. Newer releases have not been tested yet.
The current release of rmfakecloud support file synchronization for SW <= 3.10.2. Newer releases have not been tested yet.

For Tablet SW > 3.X, rendering of the notebooks [is not yet supported](https://github.com/ddvk/rmfakecloud/issues/255).

Expand Down
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 := messages.MissingFiles{}

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

c.JSON(http.StatusOK, mfs)
}

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

// 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 783da33

Please sign in to comment.