This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit 90d3920be68fa9dc82ab04ec8381e0b5df3c3a2d Author: Anan <[email protected]> AuthorDate: Wed Oct 16 01:36:12 2024 +0000 With slash command /ask --- notification-slack/config.go | 2 +- notification-slack/go.mod | 4 +--- notification-slack/info.yaml | 2 +- notification-slack/slack_notification.go | 2 +- notification-slack/user_config.go | 2 +- user-center-slack/config.go | 6 +----- user-center-slack/go.mod | 4 +--- user-center-slack/go.sum | 2 ++ user-center-slack/importer.go | 21 +++++++-------------- user-center-slack/info.yaml | 2 +- user-center-slack/notification.go | 2 +- user-center-slack/slack_user_center.go | 2 +- user-center-slack/user_config.go | 2 +- 13 files changed, 20 insertions(+), 33 deletions(-) diff --git a/notification-slack/config.go b/notification-slack/config.go index 8afd16e..7f23057 100644 --- a/notification-slack/config.go +++ b/notification-slack/config.go @@ -22,7 +22,7 @@ package slack_notification import ( "encoding/json" - "github.com/Anan1225/incubator-answer-plugins/notification-slack/i18n" + "github.com/apache/incubator-answer-plugins/notification-slack/i18n" "github.com/apache/incubator-answer/plugin" ) diff --git a/notification-slack/go.mod b/notification-slack/go.mod index 3adb597..894b18b 100644 --- a/notification-slack/go.mod +++ b/notification-slack/go.mod @@ -1,4 +1,4 @@ -module github.com/Anan1225/incubator-answer-plugins/notification-slack +module github.com/apache/incubator-answer-plugins/notification-slack go 1.19 @@ -46,5 +46,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -replace github.com/Anan1225/incubator-answer-plugins/notification-slack => /root/incubator-answer-plugins/notification-slack diff --git a/notification-slack/info.yaml b/notification-slack/info.yaml index 92f4897..7c034f0 100644 --- a/notification-slack/info.yaml +++ b/notification-slack/info.yaml @@ -19,4 +19,4 @@ slug_name: slack_notification type: notification version: 1.0.2 author: answerdev -link: https://github.com/Anan1225/incubator-answer-plugins/tree/main/notification-slack +link: https://github.com/apache/incubator-answer-plugins/tree/main/notification-slack diff --git a/notification-slack/slack_notification.go b/notification-slack/slack_notification.go index 4366481..7905bc0 100644 --- a/notification-slack/slack_notification.go +++ b/notification-slack/slack_notification.go @@ -26,7 +26,7 @@ import ( "github.com/apache/incubator-answer-plugins/util" "github.com/go-resty/resty/v2" - slackI18n "github.com/Anan1225/incubator-answer-plugins/notification-slack/i18n" + slackI18n "github.com/apache/incubator-answer-plugins/notification-slack/i18n" "github.com/apache/incubator-answer/plugin" "github.com/segmentfault/pacman/i18n" "github.com/segmentfault/pacman/log" diff --git a/notification-slack/user_config.go b/notification-slack/user_config.go index b7f5ee5..44145da 100644 --- a/notification-slack/user_config.go +++ b/notification-slack/user_config.go @@ -24,7 +24,7 @@ import ( "fmt" "sync" - "github.com/Anan1225/incubator-answer-plugins/notification-slack/i18n" + "github.com/apache/incubator-answer-plugins/notification-slack/i18n" "github.com/apache/incubator-answer/plugin" "github.com/segmentfault/pacman/log" ) diff --git a/user-center-slack/config.go b/user-center-slack/config.go index 897c7a5..2e6420f 100644 --- a/user-center-slack/config.go +++ b/user-center-slack/config.go @@ -23,7 +23,7 @@ import ( "encoding/json" "time" - "github.com/Anan1225/incubator-answer-plugins/user-center-slack/i18n" + "github.com/apache/incubator-answer-plugins/user-center-slack/i18n" "github.com/apache/incubator-answer/plugin" ) @@ -149,9 +149,5 @@ func (uc *UserCenter) ConfigReceiver(config []byte) error { uc.Config = c uc.SlackClient = NewSlackClient(c.ClientID, c.ClientSecret) - - if uc.Config.AutoSync { - uc.CronSyncData() - } return nil } diff --git a/user-center-slack/go.mod b/user-center-slack/go.mod index e5cb490..50786fa 100644 --- a/user-center-slack/go.mod +++ b/user-center-slack/go.mod @@ -1,4 +1,4 @@ -module github.com/Anan1225/incubator-answer-plugins/user-center-slack +module github.com/apache/incubator-answer-plugins/user-center-slack go 1.22.7 @@ -51,5 +51,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) - -replace github.com/apache/incubator-answer => /root/incubator-answer diff --git a/user-center-slack/go.sum b/user-center-slack/go.sum index 388f607..335f91e 100644 --- a/user-center-slack/go.sum +++ b/user-center-slack/go.sum @@ -2,6 +2,8 @@ github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/LinkinStars/go-i18n/v2 v2.2.2 h1:ZfjpzbW13dv6btv3RALKZkpN9A+7K1JA//2QcNeWaxU= github.com/LinkinStars/go-i18n/v2 v2.2.2/go.mod h1:hLglSJ4/3M0Y7ZVcoEJI+OwqkglHCA32DdjuJJR2LbM= +github.com/apache/incubator-answer v1.4.0 h1:W3y4TAQ4sdzgcqntGqNBPe0BdyeW7+l8FWYBDs9g8+Y= +github.com/apache/incubator-answer v1.4.0/go.mod h1:Q4NkQmBd0sV7t3Cd8NBsWh9w8jFRo/2qjzOw9MlRNwk= github.com/apache/incubator-answer-plugins/util v1.0.2 h1:PontocVaiEm+oTj+4aDonwWDZnxywUeHsaTwlQgclfA= github.com/apache/incubator-answer-plugins/util v1.0.2/go.mod h1:KPMSiM4ec4uEl2njaGINYuSl6zVmHdvPB2nHUxVcQDo= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= diff --git a/user-center-slack/importer.go b/user-center-slack/importer.go index 0e3984d..f4debd0 100644 --- a/user-center-slack/importer.go +++ b/user-center-slack/importer.go @@ -70,11 +70,6 @@ func getSlackUserEmail(userID, token string) (string, error) { if err := json.Unmarshal(body, &userResponse); err != nil { return "", err } - - fmt.Println("===UserResponse===Begin") - fmt.Println(userResponse) - fmt.Println("===UserResponse===End") - if !userResponse.Ok { return "", fmt.Errorf("failed to get user info from Slack") } @@ -146,8 +141,7 @@ func (uc *UserCenter) SlashCommand(ctx *gin.Context) { body, _ := io.ReadAll(ctx.Request.Body) ctx.Request.Body = io.NopCloser(bytes.NewBuffer(body)) cmd := ctx.PostForm("command") - // FIXME: Change to /ask - if cmd != "/ask2" { + if cmd != "/ask" { log.Errorf("error: Invalid command") ctx.JSON(http.StatusBadRequest, gin.H{"text": "Invalid command"}) return @@ -166,17 +160,16 @@ func (uc *UserCenter) SlashCommand(ctx *gin.Context) { ctx.JSON(200, gin.H{"text": err.Error()}) return } - fmt.Println("===Title===Begin") - fmt.Println(questionInfo.Title) - fmt.Println(questionInfo.Content) - fmt.Println(questionInfo.Tags) - fmt.Println(questionInfo.UserEmail) - fmt.Println("===Title===End") if uc.importerFunc == nil { log.Errorf("error: importerFunc is not initialized") return } - uc.importerFunc.AddQuestion(ctx, questionInfo) + err = uc.importerFunc.AddQuestion(ctx, questionInfo) + if err != nil { + log.Errorf("error: %v", err) + ctx.JSON(http.StatusBadRequest, gin.H{"text": "Failed to add question"}) + return + } ctx.JSON(http.StatusOK, gin.H{"text": "Question has been added successfully"}) } diff --git a/user-center-slack/info.yaml b/user-center-slack/info.yaml index 8e3db48..21addf0 100644 --- a/user-center-slack/info.yaml +++ b/user-center-slack/info.yaml @@ -19,4 +19,4 @@ slug_name: slack_user_center type: user_center version: 1.0.1 author: answerdev -link: https://github.com/Anan1225/incubator-answer-plugins/tree/main/user-center-slack +link: https://github.com/apache/incubator-answer-plugins/tree/main/user-center-slack diff --git a/user-center-slack/notification.go b/user-center-slack/notification.go index a08b40d..799ec91 100644 --- a/user-center-slack/notification.go +++ b/user-center-slack/notification.go @@ -3,7 +3,7 @@ package slack_user_center import ( "strings" - slackI18n "github.com/Anan1225/incubator-answer-plugins/user-center-slack/i18n" + slackI18n "github.com/apache/incubator-answer-plugins/user-center-slack/i18n" "github.com/apache/incubator-answer/plugin" "github.com/go-resty/resty/v2" "github.com/segmentfault/pacman/i18n" diff --git a/user-center-slack/slack_user_center.go b/user-center-slack/slack_user_center.go index e5f4e44..33f3ce8 100644 --- a/user-center-slack/slack_user_center.go +++ b/user-center-slack/slack_user_center.go @@ -28,7 +28,7 @@ import ( "github.com/apache/incubator-answer-plugins/util" - "github.com/Anan1225/incubator-answer-plugins/user-center-slack/i18n" + "github.com/apache/incubator-answer-plugins/user-center-slack/i18n" "github.com/apache/incubator-answer/plugin" "github.com/gin-gonic/gin" "github.com/patrickmn/go-cache" diff --git a/user-center-slack/user_config.go b/user-center-slack/user_config.go index e39c3a8..c2885f0 100644 --- a/user-center-slack/user_config.go +++ b/user-center-slack/user_config.go @@ -24,7 +24,7 @@ import ( "fmt" "sync" - "github.com/Anan1225/incubator-answer-plugins/user-center-slack/i18n" + "github.com/apache/incubator-answer-plugins/user-center-slack/i18n" "github.com/apache/incubator-answer/plugin" "github.com/segmentfault/pacman/log" )
