Skip to content

Commit

Permalink
修改事件逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
xl-wenqiang committed Feb 20, 2021
1 parent 4210b19 commit fdda5f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.1.2</Version>
<Version>0.1.3</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>雪雁</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,22 @@ public async Task<ActionResult> HandleMessage(string signature, string timestamp
{
logger.LogDebug("正在处理微信服务器消息...");

using (var reader = new StreamReader(Request.Body))
using var reader = new StreamReader(Request.Body);
var xmlStr = await reader.ReadToEndAsync();
//检查签名
if (!serverMessageHandler.CheckSignature(signature, timestamp, nonce))
{
var xmlStr = reader.ReadToEnd();
//检查签名
if (!serverMessageHandler.CheckSignature(signature, timestamp, nonce))
{
logger.LogWarning($"签名验证出错:\n signature:{signature}\t timestamp:{timestamp}\t nonce:{nonce}\t echostr:{echostr}");
return BadRequest("签名验证出错!");
}
//处理事件消息
var result = await serverMessageHandler.HandleMessage(xmlStr);
if (result == null)
return Ok();
var toXml = result.ToXml();
logger.LogDebug($"微信服务器事件处理成功,返回格式为:{Environment.NewLine}{toXml}");
return Content(toXml);
logger.LogWarning($"签名验证出错:\n signature:{signature}\t timestamp:{timestamp}\t nonce:{nonce}\t echostr:{echostr}");
return BadRequest("签名验证出错!");
}
logger.LogDebug("签名校验完成...");
//处理事件消息
var result = await serverMessageHandler.HandleMessage(xmlStr);
if (result == null)
return Ok();
var toXml = result.ToXml();
logger.LogDebug($"微信服务器事件处理成功,返回格式为:{Environment.NewLine}{toXml}");
return Content(toXml);
}
}
}

0 comments on commit fdda5f1

Please sign in to comment.