add basic update functionality
If enabled, jfa-go pings buildrone (hosted at builds.hrfee.pw) every 30 min for new updates. If there is one, it gets information (and if applicable, a binary) from the appropriate source (buildrone, github, or dockerhub) and displays it on the admin page. You can switch update channels between stable and unstable. For binary releases, updates are downloaded automatically and installed when the user presses update. Since this obviously introduces some "phone-home" functionality into jfa-go, I just want to say IPs are not and will not be logged by buildrone, although I may later introduce functionality to give a rough idea of the number of users (again, no IPs stored). The whole thing can also be turned off in settings.
This commit is contained in:
@@ -1440,6 +1440,39 @@ func (app *appContext) SetEmailState(gc *gin.Context) {
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
// @Summary Returns whether there's a new update, and extra info if there is.
|
||||
// @Produce json
|
||||
// @Success 200 {object} checkUpdateDTO
|
||||
// @Router /config/update [get]
|
||||
// @tags Configuration
|
||||
func (app *appContext) CheckUpdate(gc *gin.Context) {
|
||||
if !app.newUpdate {
|
||||
app.update = Update{}
|
||||
}
|
||||
gc.JSON(200, checkUpdateDTO{New: app.newUpdate, Update: app.update})
|
||||
}
|
||||
|
||||
// @Summary Apply an update.
|
||||
// @Produce json
|
||||
// @Success 200 {object} boolResponse
|
||||
// @Success 400 {object} stringResponse
|
||||
// @Success 500 {object} boolResponse
|
||||
// @Router /config/update [post]
|
||||
// @tags Configuration
|
||||
func (app *appContext) ApplyUpdate(gc *gin.Context) {
|
||||
if !app.update.CanUpdate {
|
||||
respond(400, "Update is manual", gc)
|
||||
return
|
||||
}
|
||||
err := app.update.update()
|
||||
if err != nil {
|
||||
app.err.Printf("Failed to apply update: %s", err)
|
||||
respondBool(500, false, gc)
|
||||
return
|
||||
}
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
// @Summary Returns the custom email (generating it if not set) and list of used variables in it.
|
||||
// @Produce json
|
||||
// @Success 200 {object} customEmailDTO
|
||||
|
||||
Reference in New Issue
Block a user