Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add importer plugin type #1122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add importer plugin type #1122

wants to merge 1 commit into from

Conversation

Anan1225
Copy link

OSPP Project

  1. To realize add questions from Slack Slash Command, add a new plugin type importer.
  2. Main function: get question detail from Client Response, then directly add question to Answer.

see issue 151 and plugin user-center-slack

@LinkinStars LinkinStars self-requested a review September 29, 2024 03:03
@LinkinStars LinkinStars self-assigned this Sep 29, 2024
Comment on lines +31 to +34
type Importer interface {
Base
GetQuestion(ctx *gin.Context) (questionInfo *QuestionImporterInfo, err error)
}
Copy link
Member

@LinkinStars LinkinStars Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Importer interface should be designed primarily for importing data. It is also designed for expansion later. So it should accept the Q&A data directly and add it to the database. May like this

type Importer interface {
	Base
	RegisterImporter(importer QuestionImporter)
}

type QuestionImporter interface {
        AddQuestions(questions *QuestionInfo) (err error)
}

FYI:

RegisterSyncer(ctx context.Context, syncer SearchSyncer)

@@ -68,6 +70,9 @@ func (pr *PluginAPIRouter) RegisterUnAuthConnectorRouter(r *gin.RouterGroup) {
r.GET("/captcha/config", pr.captchaController.GetCaptchaConfig)
r.GET("/embed/config", pr.embedController.GetEmbedConfig)
r.GET("/render/config", pr.renderController.GetRenderConfig)

// importer plugin
r.POST("/importer/answer", pr.importerController.ImportCommand)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the design of the interface, it is clear that there is a problem here. The API exposed here is not authenticated, which means that any user can use this interface to add data, which is unsafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants