Mock repository update

This commit is contained in:
nemunaire 2022-09-04 23:54:10 +02:00
commit 8d9245f1b1
3 changed files with 33 additions and 3 deletions

View file

@ -111,6 +111,22 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
c.JSON(http.StatusOK, nil)
}
})
repositoriesRoutes.POST("/trigger", func(c *gin.Context) {
repo := c.MustGet("repository").(*Repository)
now := time.Now()
if !repo.LastCheck.Before(now.Add(-5 * time.Minute)) {
c.AbortWithStatusJSON(http.StatusPaymentRequired, gin.H{"errmsg": "Please wait between two pulls."})
return
}
repo.LastCheck = &now
repo.Update()
c.JSON(http.StatusOK, repo)
})
}
func repositoryHandler(c *gin.Context) {