MCPcopy Create free account
hub / github.com/QuantumNous/new-api / GetTaskPlugin

Function GetTaskPlugin

controller/task_plugin.go:331–360  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

329}
330
331func GetTaskPlugin(c *gin.Context) {
332 key := c.Param("key")
333 version := c.Query("version")
334 plugin, err := model.GetTaskPluginVersion(key, version)
335 if err == nil {
336 loaded, compileErr := jsplugin.NewRegistry().Register(plugin.Source, jsplugin.Options{Key: plugin.Key, Version: plugin.Version})
337 if compileErr != nil {
338 common.ApiErrorMsg(c, compileErr.Error())
339 return
340 }
341 common.ApiSuccess(c, taskPluginDetail{Plugin: plugin, Meta: loaded.Meta, Source: plugin.Source, Layer: "override", HasIcon: plugin.HasIcon()})
342 return
343 }
344 if !errors.Is(err, gorm.ErrRecordNotFound) || version != "" {
345 common.ApiError(c, err)
346 return
347 }
348 source, err := plugins.Source(key)
349 if err != nil {
350 common.ApiErrorMsg(c, "task plugin not found")
351 return
352 }
353 loaded, err := jsplugin.NewRegistry().RegisterFactory(source, jsplugin.Options{Key: key})
354 if err != nil {
355 common.ApiError(c, err)
356 return
357 }
358 _, _, hasIcon := plugins.Icon(key)
359 common.ApiSuccess(c, taskPluginDetail{Meta: loaded.Meta, Source: source, Layer: "factory", HasIcon: hasIcon})
360}
361
362type taskPluginDryRunRequest struct {
363 Hook string `json:"hook" binding:"required"`

Callers

nothing calls this directly

Calls 12

GetTaskPluginVersionFunction · 0.92
NewRegistryFunction · 0.92
ApiErrorMsgFunction · 0.92
ApiSuccessFunction · 0.92
ApiErrorFunction · 0.92
SourceFunction · 0.92
IconFunction · 0.92
QueryMethod · 0.80
HasIconMethod · 0.80
RegisterFactoryMethod · 0.80
RegisterMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected