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

Method SetPluginEnabled

plugin/manager.go:117–148  ·  view source on GitHub ↗

SetPluginEnabled sets the plugins enabled state.

(pluginID uint, enabled bool)

Source from the content-addressed store, hash-verified

115
116// SetPluginEnabled sets the plugins enabled state.
117func (m *Manager) SetPluginEnabled(pluginID uint, enabled bool) error {
118 instance, err := m.Instance(pluginID)
119 if err != nil {
120 return errors.New("instance not found")
121 }
122 conf, err := m.db.GetPluginConfByID(pluginID)
123 if err != nil {
124 return err
125 }
126
127 if conf.Enabled == enabled {
128 return ErrAlreadyEnabledOrDisabled
129 }
130
131 m.mutex.Lock()
132 defer m.mutex.Unlock()
133
134 if enabled {
135 err = instance.Enable()
136 } else {
137 err = instance.Disable()
138 }
139 if err != nil {
140 return err
141 }
142
143 if newConf, err := m.db.GetPluginConfByID(pluginID); /* conf might be updated by instance */ err == nil {
144 conf = newConf
145 }
146 conf.Enabled = enabled
147 return m.db.UpdatePluginConf(conf)
148}
149
150// PluginInfo returns plugin info.
151func (m *Manager) PluginInfo(modulePath string) compat.Info {

Calls 5

InstanceMethod · 0.95
GetPluginConfByIDMethod · 0.65
EnableMethod · 0.65
DisableMethod · 0.65
UpdatePluginConfMethod · 0.65