Browse Source

feat: support privacy policy

Yeuoly 7 months ago
parent
commit
80f4d1c056

+ 9 - 1
cmd/commandline/plugin/init.go

@@ -13,6 +13,7 @@ import (
 	"github.com/langgenius/dify-plugin-daemon/internal/types/entities/manifest_entities"
 	"github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
 	"github.com/langgenius/dify-plugin-daemon/internal/utils/log"
+	"github.com/langgenius/dify-plugin-daemon/internal/utils/parser"
 )
 
 //go:embed templates/python/icon.svg
@@ -148,7 +149,8 @@ func (m model) createPlugin() {
 				Memory:     1024 * 1024 * 256, // 256MB
 				Permission: &permission,
 			},
-			Label: plugin_entities.NewI18nObject(m.subMenus[SUB_MENU_KEY_PROFILE].(profile).Name()),
+			Label:   plugin_entities.NewI18nObject(m.subMenus[SUB_MENU_KEY_PROFILE].(profile).Name()),
+			Privacy: parser.ToPtr("PRIVACY.md"),
 		},
 	}
 
@@ -240,6 +242,12 @@ func (m model) createPlugin() {
 		return
 	}
 
+	// create PRIVACY.md
+	if err := writeFile(filepath.Join(pluginDir, "PRIVACY.md"), string(PRIVACY)); err != nil {
+		log.Error("failed to write PRIVACY file: %s", err)
+		return
+	}
+
 	err = createPythonEnvironment(
 		pluginDir,
 		manifest.Meta.Runner.Entrypoint,

+ 3 - 0
cmd/commandline/plugin/template.go

@@ -9,3 +9,6 @@ var README []byte
 
 //go:embed templates/.env.example
 var ENV_EXAMPLE []byte
+
+//go:embed templates/PRIVACY.md
+var PRIVACY []byte

+ 3 - 0
cmd/commandline/plugin/templates/PRIVACY.md

@@ -0,0 +1,3 @@
+## Privacy
+
+!!! Please fill in the privacy policy of the plugin.

+ 5 - 0
cmd/commandline/plugin/templates/python/GUIDE.md

@@ -110,3 +110,8 @@ dify-plugin plugin package ./ROOT_DIRECTORY_OF_YOUR_PLUGIN
 ```
 
 you will get a `plugin.difypkg` file, that's all, you can submit it to the Marketplace now, look forward to your Plugin being listed!
+
+
+## User Privacy Policy
+
+Please fill in the privacy policy of the plugin if you want to make it published on the Marketplace, refer to [PRIVACY.md](PRIVACY.md) for more details.

+ 1 - 0
internal/types/entities/plugin_entities/plugin_declaration.go

@@ -151,6 +151,7 @@ type PluginDeclarationWithoutAdvancedFields struct {
 	Meta        PluginMeta                         `json:"meta" yaml:"meta,omitempty" validate:"required"`
 	Tags        []manifest_entities.PluginTag      `json:"tags" yaml:"tags,omitempty" validate:"omitempty,dive,plugin_tag,max=128"`
 	CreatedAt   time.Time                          `json:"created_at" yaml:"created_at,omitempty" validate:"required"`
+	Privacy     *string                            `json:"privacy,omitempty" yaml:"privacy,omitempty" validate:"omitempty"`
 }
 
 func (p *PluginDeclarationWithoutAdvancedFields) UnmarshalJSON(data []byte) error {