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

Method EnablePlugin

api/plugin.go:124–145  ·  view source on GitHub ↗

EnablePlugin enables a plugin. swagger:operation POST /plugin/{id}/enable plugin enablePlugin Enable a plugin. --- consumes: [application/json] produces: [application/json] parameters: - name: id in: path description: the plugin id required: true type: integer format: int64 se

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

122// schema:
123// $ref: "#/definitions/Error"
124func (c *PluginAPI) EnablePlugin(ctx *gin.Context) {
125 withID(ctx, "id", func(id uint) {
126 conf, err := c.DB.GetPluginConfByID(id)
127 if success := successOrAbort(ctx, 500, err); !success {
128 return
129 }
130 if conf == nil || !isPluginOwner(ctx, conf) {
131 ctx.AbortWithError(404, errors.New("unknown plugin"))
132 return
133 }
134 _, err = c.Manager.Instance(id)
135 if err != nil {
136 ctx.AbortWithError(404, errors.New("plugin instance not found"))
137 return
138 }
139 if err := c.Manager.SetPluginEnabled(id, true); err == plugin.ErrAlreadyEnabledOrDisabled {
140 ctx.AbortWithError(400, err)
141 } else if err != nil {
142 ctx.AbortWithError(500, err)
143 }
144 })
145}
146
147// DisablePlugin disables a plugin.
148// swagger:operation POST /plugin/{id}/disable plugin disablePlugin

Calls 6

withIDFunction · 0.85
successOrAbortFunction · 0.85
isPluginOwnerFunction · 0.85
InstanceMethod · 0.80
SetPluginEnabledMethod · 0.80
GetPluginConfByIDMethod · 0.65