MCPcopy
hub / github.com/gotify/server / UpdateApplication

Method UpdateApplication

api/application.go:250–276  ·  view source on GitHub ↗

UpdateApplication updates an application info by its id. swagger:operation PUT /application/{id} application updateApplication Update an application. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQ

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

248// schema:
249// $ref: "#/definitions/Error"
250func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
251 withID(ctx, "id", func(id uint) {
252 app, err := a.DB.GetApplicationByID(id)
253 if success := successOrAbort(ctx, 500, err); !success {
254 return
255 }
256 if app != nil && app.UserID == auth.GetUserID(ctx) {
257 applicationParams := ApplicationParams{}
258 if err := ctx.Bind(&applicationParams); err == nil {
259 app.Description = applicationParams.Description
260 app.Name = applicationParams.Name
261 app.DefaultPriority = applicationParams.DefaultPriority
262 if applicationParams.SortKey != "" {
263 app.SortKey = applicationParams.SortKey
264 }
265
266 if err := a.DB.UpdateApplication(app); err != nil {
267 handleApplicationError(ctx, err)
268 return
269 }
270 ctx.JSON(200, withResolvedImage(app))
271 }
272 } else {
273 ctx.AbortWithError(404, fmt.Errorf("app with id %d doesn't exists", id))
274 }
275 })
276}
277
278// UploadApplicationImage uploads an image for an application.
279// swagger:operation POST /application/{id}/image application uploadAppImage

Callers

nothing calls this directly

Calls 8

GetUserIDFunction · 0.92
withIDFunction · 0.85
successOrAbortFunction · 0.85
handleApplicationErrorFunction · 0.85
withResolvedImageFunction · 0.85
ErrorfMethod · 0.80
GetApplicationByIDMethod · 0.65
UpdateApplicationMethod · 0.65

Tested by

no test coverage detected