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

Method DeleteApplication

api/application.go:184–205  ·  view source on GitHub ↗

DeleteApplication deletes an application by its id. swagger:operation DELETE /application/{id} application deleteApp Delete an application. --- consumes: [application/json] produces: [application/json] parameters: - name: id in: path description: the application id required: true

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

182// schema:
183// $ref: "#/definitions/Error"
184func (a *ApplicationAPI) DeleteApplication(ctx *gin.Context) {
185 withID(ctx, "id", func(id uint) {
186 app, err := a.DB.GetApplicationByID(id)
187 if success := successOrAbort(ctx, 500, err); !success {
188 return
189 }
190 if app != nil && app.UserID == auth.GetUserID(ctx) {
191 if app.Internal {
192 ctx.AbortWithError(400, errors.New("cannot delete internal application"))
193 return
194 }
195 if success := successOrAbort(ctx, 500, a.DB.DeleteApplicationByID(id)); !success {
196 return
197 }
198 if app.Image != "" {
199 os.Remove(a.ImageDir + app.Image)
200 }
201 } else {
202 ctx.AbortWithError(404, fmt.Errorf("app with id %d doesn't exists", id))
203 }
204 })
205}
206
207// UpdateApplication updates an application info by its id.
208// swagger:operation PUT /application/{id} application updateApplication

Calls 6

GetUserIDFunction · 0.92
withIDFunction · 0.85
successOrAbortFunction · 0.85
ErrorfMethod · 0.80
GetApplicationByIDMethod · 0.65
DeleteApplicationByIDMethod · 0.65