This commit is contained in:
richboo111
2023-06-16 17:34:16 +08:00
parent f9937c22f8
commit 14fdcb1e1b
3 changed files with 21 additions and 187 deletions

View File

@@ -1,6 +1,7 @@
package mtwmapi
import (
"encoding/json"
"net/http"
"net/url"
"strings"
@@ -154,19 +155,30 @@ func (a *API) GetIMCallbackMsg(request *http.Request) (msg *ImCallbackMsg, callb
var (
err = request.ParseForm()
pushContent PushContentReq
tData string
)
msg = &ImCallbackMsg{}
msg.FormData = make(url.Values)
if err == nil {
data := utils.URLValues2Map(request.Form)
if dataSign, ok := data[signKey]; ok {
for k, v := range data {
if k == "push_content" {
//tData, _ = json.Marshal(v)
tData = v.(string)
continue
}
msg.FormData.Set(k, v.(string))
}
msg.Timestamp = utils.Str2Int(msg.FormData.Get("timestamp"))
msg.Sig = dataSign.(string)
msg.AppID = msg.FormData.Get("app_id")
if err = utils.Map2StructByJson(data, pushContent, true); err == nil {
if err = json.Unmarshal([]byte(tData), &pushContent); err == nil {
msg.PushContent = pushContent
}
//if err = utils.Map2StructByJson(tData, &pushContent, true); err == nil {
// msg.PushContent = pushContent
//}
} else {
callbackResponse = SuccessResponse
}