浏览代码

fix: update push setting prompts

JustSong 2 年之前
父节点
当前提交
d9362cb7d0
共有 3 个文件被更改,包括 25 次插入50 次删除
  1. 0 24
      controller/misc.go
  2. 0 1
      router/api-router.go
  3. 25 25
      web/src/components/PushSetting.js

+ 0 - 24
controller/misc.go

@@ -1,16 +1,12 @@
 package controller
 
 import (
-	"crypto/sha1"
-	"encoding/hex"
 	"encoding/json"
 	"fmt"
 	"github.com/gin-gonic/gin"
 	"message-pusher/common"
 	"message-pusher/model"
 	"net/http"
-	"sort"
-	"strings"
 )
 
 func GetStatus(c *gin.Context) {
@@ -171,23 +167,3 @@ func ResetPassword(c *gin.Context) {
 	})
 	return
 }
-
-func WeChatTestAccountVerification(c *gin.Context) {
-	user := model.User{Username: c.Param("username")}
-	user.FillUserByUsername()
-	// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html
-	signature := c.Query("signature")
-	timestamp := c.Query("timestamp")
-	nonce := c.Query("nonce")
-	echoStr := c.Query("echostr")
-	arr := []string{user.WeChatTestAccountVerificationToken, timestamp, nonce}
-	sort.Strings(arr)
-	str := strings.Join(arr, "")
-	hash := sha1.Sum([]byte(str))
-	hexStr := hex.EncodeToString(hash[:])
-	if signature == hexStr {
-		c.String(http.StatusOK, echoStr)
-	} else {
-		c.Status(http.StatusForbidden)
-	}
-}

+ 0 - 1
router/api-router.go

@@ -13,7 +13,6 @@ func SetApiRouter(router *gin.Engine) {
 		apiRouter.GET("/status", controller.GetStatus)
 		apiRouter.GET("/notice", controller.GetNotice)
 		apiRouter.GET("/about", controller.GetAbout)
-		apiRouter.GET("/wechat_test_account_verification/:username", controller.WeChatTestAccountVerification)
 		apiRouter.GET("/verification", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendEmailVerification)
 		apiRouter.GET("/reset_password", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendPasswordResetEmail)
 		apiRouter.POST("/user/reset", middleware.CriticalRateLimit(), controller.ResetPassword)

+ 25 - 25
web/src/components/PushSetting.js

@@ -19,7 +19,6 @@ const PushSetting = () => {
     wechat_test_account_secret: '',
     wechat_test_account_template_id: '',
     wechat_test_account_open_id: '',
-    wechat_test_account_verification_token: '',
     wechat_corp_account_id: '',
     wechat_corp_account_agent_secret: '',
     wechat_corp_account_agent_id: '',
@@ -81,8 +80,6 @@ const PushSetting = () => {
         data.wechat_test_account_template_id =
           inputs.wechat_test_account_template_id;
         data.wechat_test_account_open_id = inputs.wechat_test_account_open_id;
-        data.wechat_test_account_verification_token =
-          inputs.wechat_test_account_verification_token;
         break;
       case 'corp':
         data.wechat_corp_account_id = inputs.wechat_corp_account_id;
@@ -135,7 +132,9 @@ const PushSetting = () => {
       <Grid.Column>
         <Form loading={loading}>
           <Header as='h3'>通用设置</Header>
-          <Message>注意:密钥类配置信息不会发送到前端显示。</Message>
+          <Message>
+            注意:密钥类配置信息不会发送到前端显示。另外浏览器可能会错误填充账户和密钥信息,请留意。
+          </Message>
           <Form.Group widths={3}>
             <Form.Select
               label='默认推送方式'
@@ -186,10 +185,8 @@ const PushSetting = () => {
             </Header.Subheader>
           </Header>
           <Message>
-            接口配置信息中的 URL 填写:
-            <code>{`${window.location.origin}/api/wechat_test_account_verification/${inputs.username}`}</code>
-            <br />
-            Token 填一个随机字符串,然后填入下方的「接口配置验证 Token」中。
+            需要新增测试模板,模板标题推荐填写为「消息推送」,模板内容必须填写为
+            {' {{'}text.DATA{'}}'}。
           </Message>
           <Form.Group widths={3}>
             <Form.Input
@@ -225,16 +222,7 @@ const PushSetting = () => {
               onChange={handleInputChange}
               autoComplete='off'
               value={inputs.wechat_test_account_open_id}
-              placeholder='测试号二维码 -> 用户列表 -> 微信号'
-            />
-            <Form.Input
-              label='接口配置验证 Token'
-              name='wechat_test_account_verification_token'
-              onChange={handleInputChange}
-              autoComplete='off'
-              type='password'
-              value={inputs.wechat_test_account_verification_token}
-              placeholder='接口配置信息 -> Token'
+              placeholder='扫描测试号二维码 -> 用户列表 -> 微信号'
             />
           </Form.Group>
           <Button onClick={() => submit('test')} loading={loading}>
@@ -254,6 +242,15 @@ const PushSetting = () => {
               </a>
             </Header.Subheader>
           </Header>
+          <Message>
+            注意,企业微信要求配置可信 IP,步骤:应用管理 -> 自建 -> 创建应用 ->
+            应用设置页面下拉中找到「企业可信 IP」,点击配置 -> 设置可信域名 ->
+            在「可调用
+            JS-SDK、跳转小程序的可信域名」下面填写一个域名,然后点击「申请校验域名」,根据提示完成校验
+            -> 之后填写服务器 IP 地址(此 IP
+            地址是消息推送服务所部署在的服务器的 IP
+            地址,未必是上面校验域名中记录的 IP 地址)。
+          </Message>
           <Form.Group widths={3}>
             <Form.Input
               label='企业 ID'
@@ -313,8 +310,8 @@ const PushSetting = () => {
           <Header as='h3'>
             飞书设置(lark)
             <Header.Subheader>
-              通过飞书群机器人进行推送,选择一个群聊 -> 设置 -> 群机器人 ->
-              添加机器人 -> 自定义机器人 -> 添加(
+              通过飞书群机器人进行推送,飞书桌面客户端的配置流程:选择一个群聊
+              -> 设置 -> 群机器人 -> 添加机器人 -> 自定义机器人 -> 添加(
               <strong>注意选中「签名校验」</strong>)。具体参见:
               <a
                 target='_blank'
@@ -351,8 +348,9 @@ const PushSetting = () => {
           <Header as='h3'>
             钉钉设置(ding)
             <Header.Subheader>
-              通过钉钉机器人进行推送,选择一个群聊 -> 群设置 -> 智能群助手 ->
-              添加机器人(点击右侧齿轮图标) -> 自定义 -> 添加(
+              通过钉钉机器人进行推送,钉钉桌面客户端的配置流程:选择一个群聊 ->
+              群设置 -> 智能群助手 -> 添加机器人(点击右侧齿轮图标) -> 自定义
+              -> 添加(
               <strong>注意选中「加密」</strong>)。具体参见:
               <a
                 target='_blank'
@@ -389,12 +387,14 @@ const PushSetting = () => {
           <Header as='h3'>
             Bark 设置(bark)
             <Header.Subheader>
-              通过 Bark 进行推送,下载 Bark 后按提示注册设备即可。
+              通过 Bark 进行推送,下载 Bark 后按提示注册设备,之后会看到一个
+              URL,例如 <code>https://api.day.app/wrsVSDRANDOM/Body Text</code>
+              ,其中 <code>wrsVSDRANDOM</code> 就是你的推送 key。
             </Header.Subheader>
           </Header>
           <Form.Group widths={2}>
             <Form.Input
-              label='Bark 地址服务器地址'
+              label='服务器地址'
               name='bark_server'
               onChange={handleInputChange}
               autoComplete='off'
@@ -402,7 +402,7 @@ const PushSetting = () => {
               placeholder='在此填写 Bark 服务器地址'
             />
             <Form.Input
-              label='签名校验密钥'
+              label='推送 key'
               name='bark_secret'
               type='password'
               onChange={handleInputChange}