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

Method DeleteClient

api/client.go:223–236  ·  view source on GitHub ↗

DeleteClient deletes a client by its id. swagger:operation DELETE /client/{id} client deleteClient Delete a client. --- consumes: [application/json] produces: [application/json] parameters: - name: id in: path description: the client id required: true type: integer format: int6

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

221// schema:
222// $ref: "#/definitions/Error"
223func (a *ClientAPI) DeleteClient(ctx *gin.Context) {
224 withID(ctx, "id", func(id uint) {
225 client, err := a.DB.GetClientByID(id)
226 if success := successOrAbort(ctx, 500, err); !success {
227 return
228 }
229 if client != nil && client.UserID == auth.GetUserID(ctx) {
230 a.NotifyDeleted(client.UserID, client.Token)
231 successOrAbort(ctx, 500, a.DB.DeleteClientByID(id))
232 } else {
233 ctx.AbortWithError(404, fmt.Errorf("client with id %d doesn't exists", id))
234 }
235 })
236}
237
238func (a *ClientAPI) clientExists(token string) bool {
239 client, _ := a.DB.GetClientByToken(token)

Calls 6

GetUserIDFunction · 0.92
withIDFunction · 0.85
successOrAbortFunction · 0.85
ErrorfMethod · 0.80
GetClientByIDMethod · 0.65
DeleteClientByIDMethod · 0.65