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

Create user center slack and integrate with importer #230

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

Conversation

Anan1225
Copy link

OSPP project

  1. Create user center Slack including login and authorization
  2. Add notification slack type with upvoted, downvoted, etc.
  3. Complete slash command function in Slack, /ask [Title][Context][Tag]

see issue151

Copy link
Member

Choose a reason for hiding this comment

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

You need to update the README.

RedirectURI string
AuthedUserID string

Enabled bool // 用户是否启用的标记
Copy link
Member

Choose a reason for hiding this comment

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

remove the comment

func (sc *SlackClient) AuthUser(code string) (info *UserInfo, err error) {
clientID := sc.ClientID
clientSecret := sc.ClientSecret
redirectURI := fmt.Sprintf("%s/answer/api/v1/user-center/login/callback", "https://as.0vo.lol")
Copy link
Member

Choose a reason for hiding this comment

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

Here you can't write a fixed URL address, you can refer to the

func (uc *UserCenter) GetRedirectURL(ctx *gin.Context) {
authorizeUrl := fmt.Sprintf("%s/answer/api/v1/user-center/login/callback", plugin.SiteURL())
redirectURL := uc.Company.GetRedirectURL(authorizeUrl)
state := genNonce()
redirectURL = strings.ReplaceAll(redirectURL, "STATE", state)
ctx.JSON(http.StatusOK, NewRespBodyData(http.StatusOK, "success", map[string]string{
"redirect_url": redirectURL,
"key": state,
}))
}

}

sc.Enabled = true
// sc.AccessToken = tokenResp.AccessToken
Copy link
Member

Choose a reason for hiding this comment

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

Remove it.

UIOptions: plugin.ConfigFieldUIOptions{
Text: syncNowLabel,
Action: &plugin.UIOptionAction{
Url: "/answer/admin/api/slack/sync", // 修改为 Slack 的同步 URL
Copy link
Member

Choose a reason for hiding this comment

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

The comment maybe out of date.

Comment on lines +154 to +156
if uc.Config.AutoSync {
uc.CronSyncData()
}
Copy link
Member

Choose a reason for hiding this comment

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

The way it is currently handled here results in a new ticker being started to synchronise the data every time the configuration is updated as long as AutoSync is true. On the one hand, we need to deal with the case where AutoSync is false, and on the other hand, we need to deal with the case where we can't turn on more than one at the same time. I hope this is understandable.

Comment on lines +54 to +78
other: 授权网址
description:
other: 企业微信授权网址
corp_id:
title:
other: 企业 ID
description:
other: 企业微信企业ID
corp_secret:
title:
other: 应用 Secret
description:
other: 企业微信应用程序密钥
agent_id:
title:
other: 应用 Agent ID
description:
other: 企业微信应用程序代理ID
notification:
label:
other: 打开通知
title:
other: 通知
description:
other: 用户将在企业微信上收到通知。
Copy link
Member

Choose a reason for hiding this comment

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

Maybe some translations is out of date.

Comment on lines +30 to +32
part1 := matches[0][1]
part2 := matches[1][1]
rawTags := strings.Split(matches[2][1], ",")
Copy link
Member

Choose a reason for hiding this comment

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

Of course in most cases there is no problem with taking [1] directly. But it's safer to judge the internal length.

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