MCPcopy Index your code
hub / github.com/gotify/server / UpdateClient

Method UpdateClient

api/client.go:84–104  ·  view source on GitHub ↗

UpdateClient updates a client by its id. swagger:operation PUT /client/{id} client updateClient Update a client. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []] parameters:

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

82// schema:
83// $ref: "#/definitions/Error"
84func (a *ClientAPI) UpdateClient(ctx *gin.Context) {
85 withID(ctx, "id", func(id uint) {
86 client, err := a.DB.GetClientByID(id)
87 if success := successOrAbort(ctx, 500, err); !success {
88 return
89 }
90 if client != nil && client.UserID == auth.GetUserID(ctx) {
91 newValues := ClientParams{}
92 if err := ctx.Bind(&newValues); err == nil {
93 client.Name = newValues.Name
94
95 if success := successOrAbort(ctx, 500, a.DB.UpdateClient(client)); !success {
96 return
97 }
98 ctx.JSON(200, client)
99 }
100 } else {
101 ctx.AbortWithError(404, fmt.Errorf("client with id %d doesn't exists", id))
102 }
103 })
104}
105
106// CreateClient creates a client and returns the access token.
107// swagger:operation POST /client client createClient

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected