diff --git a/platform/elmapi/callback.go b/platform/elmapi/callback.go index 10f70769..eb672a16 100644 --- a/platform/elmapi/callback.go +++ b/platform/elmapi/callback.go @@ -22,14 +22,14 @@ type ELMCallbackResponse struct { } type ELMCallbackMsg struct { - AppId int `json:"appId"` - RequestId string `json:"requestId"` - Type int `json:"type"` - Message string `json:"message"` - ShopId int `json:"shopId"` - Timestamp int64 `json:"timestamp"` - UserId int64 `json:"userId"` - Signature string `json:"signature"` + AppId int `json:"appId" structs:"appId"` + RequestId string `json:"requestId" structs:"requestId"` + Type int `json:"type" structs:"type"` + Message string `json:"message" structs:"message"` + ShopId int `json:"shopId" structs:"shopId"` + Timestamp int64 `json:"timestamp" structs:"timestamp"` + UserId int64 `json:"userId" structs:"userId"` + Signature string `json:"signature" structs:"signature"` } var ( @@ -48,8 +48,8 @@ func (e *ELMAPI) unmarshalData(data []byte, msg interface{}) (callbackResponse * func (e *ELMAPI) CheckRequestValidation(mapData map[string]interface{}) (callbackResponse *ELMCallbackResponse) { sign := e.signParamsMap(mapData, "") - if sign != mapData[signKey].(string) { - e.sugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, mapData[signKey].(string)) + if remoteSign, ok := mapData[signKey].(string); ok && sign != remoteSign { + e.sugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, remoteSign) return &ELMCallbackResponse{Message: "signature is invalid"} } return nil