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

Function UpdateTaskPluginMarketplaceSources

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

Source from the content-addressed store, hash-verified

875}
876
877func UpdateTaskPluginMarketplaceSources(c *gin.Context) {
878 var sources []setting.TaskPluginMarketplaceSource
879 if err := c.ShouldBindJSON(&sources); err != nil {
880 common.ApiErrorMsg(c, err.Error())
881 return
882 }
883 if sources == nil {
884 sources = []setting.TaskPluginMarketplaceSource{}
885 }
886 for i := range sources {
887 name := strings.TrimSpace(sources[i].Name)
888 indexURL := strings.TrimSpace(sources[i].IndexURL)
889 if name == "" {
890 common.ApiErrorMsg(c, "marketplace source name is required")
891 return
892 }
893 parsed, err := url.Parse(indexURL)
894 if err != nil || !parsed.IsAbs() || parsed.Host == "" || (!strings.EqualFold(parsed.Scheme, "http") && !strings.EqualFold(parsed.Scheme, "https")) {
895 common.ApiErrorMsg(c, "marketplace source index_url must be an absolute http(s) URL")
896 return
897 }
898 sources[i].Name = name
899 sources[i].IndexURL = indexURL
900 }
901 encoded, err := common.Marshal(sources)
902 if err != nil {
903 common.ApiError(c, err)
904 return
905 }
906 if err = model.UpdateOption(setting.TaskPluginMarketplaceSourcesKey, string(encoded)); err != nil {
907 common.ApiError(c, err)
908 return
909 }
910 common.ApiSuccess(c, sources)
911}
912
913// relayPaths lists the incoming paths of a plugin's relay routes, each once.
914func relayPaths(meta jsplugin.Meta) []string {

Calls 6

ApiErrorMsgFunction · 0.92
MarshalFunction · 0.92
ApiErrorFunction · 0.92
UpdateOptionFunction · 0.92
ApiSuccessFunction · 0.92
ErrorMethod · 0.45