feat: now user are able to configure channels

This commit is contained in:
JustSong
2022-11-22 17:52:44 +08:00
parent e911c3fb7c
commit 2acc56e03c
10 changed files with 470 additions and 32 deletions
+24
View File
@@ -1,12 +1,16 @@
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) {
@@ -167,3 +171,23 @@ 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)
}
}