-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from EasyAbp/official-events
Introduce WeChat official account event handling
- Loading branch information
Showing
41 changed files
with
466 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...stHandling/Dtos/AppEventHandlingResult.cs → ...stHandling/Dtos/AppEventHandlingResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...stHandling/Dtos/IResponseToWeChatModel.cs → ...stHandling/Dtos/IResponseToWeChatModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...andling/Dtos/JsonResponseToWeChatModel.cs → ...andling/Dtos/JsonResponseToWeChatModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...Abp.Abp.WeChat.Common.Abstractions/RequestHandling/Dtos/PlainTextResponseToWeChatModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace EasyAbp.Abp.WeChat.Common.RequestHandling.Dtos; | ||
|
||
public class PlainTextResponseToWeChatModel : IResponseToWeChatModel | ||
{ | ||
public string Content { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Handling/Dtos/XmlResponseToWeChatModel.cs → ...Handling/Dtos/XmlResponseToWeChatModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...Common/EasyAbp.Abp.WeChat.Common/RequestHandling/WeChatEventRequestHandlingServiceBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Threading.Tasks; | ||
using EasyAbp.Abp.WeChat.Common.Infrastructure.Encryption; | ||
using EasyAbp.Abp.WeChat.Common.Infrastructure.Options; | ||
using EasyAbp.Abp.WeChat.Common.RequestHandling.Dtos; | ||
using Volo.Abp.ObjectExtending; | ||
|
||
namespace EasyAbp.Abp.WeChat.Common.RequestHandling; | ||
|
||
public class WeChatEventRequestHandlingServiceBase<TOptions> where TOptions : IAbpWeChatOptions | ||
{ | ||
protected IWeChatNotificationEncryptor WeChatNotificationEncryptor { get; } | ||
|
||
public WeChatEventRequestHandlingServiceBase(IWeChatNotificationEncryptor weChatNotificationEncryptor) | ||
{ | ||
WeChatNotificationEncryptor = weChatNotificationEncryptor; | ||
} | ||
|
||
protected virtual async Task<T> DecryptMsgAsync<T>(TOptions options, | ||
WeChatEventRequestModel request) where T : ExtensibleObject, new() | ||
{ | ||
return await WeChatNotificationEncryptor.DecryptAsync<T>( | ||
options.Token, | ||
options.EncodingAesKey, | ||
options.AppId, | ||
request.MsgSignature, | ||
request.Timestamp, | ||
request.Nonce, | ||
request.PostData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...al/EasyAbp.Abp.WeChat.Official.Abstractions/RequestHandling/GetAccessTokenByCodeResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...asyAbp.Abp.WeChat.Official.Abstractions/RequestHandling/GetJsSdkConfigParametersResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Chat.Official.Abstractions/RequestHandling/IWeChatOfficialClientRequestHandlingService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
...eChat.Official.Abstractions/RequestHandling/IWeChatOfficialEventRequestHandlingService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Official/EasyAbp.Abp.WeChat.Official.Abstractions/RequestHandling/RedirectUrlRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...bp.WeChat.Official.Abstractions/RequestHandling/StringValueWeChatRequestHandlingResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/Official/EasyAbp.Abp.WeChat.Official.Abstractions/RequestHandling/VerifyRequestDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...syAbp.Abp.WeChat.Official.Abstractions/RequestHandling/WeChatOfficialEventRequestModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using EasyAbp.Abp.WeChat.Common.RequestHandling.Dtos; | ||
|
||
namespace EasyAbp.Abp.WeChat.Official.RequestHandling; | ||
|
||
[Serializable] | ||
public class WeChatOfficialEventRequestModel : WeChatEventRequestModel | ||
{ | ||
/// <summary> | ||
/// 用于微信公众号验证 | ||
/// </summary> | ||
public string EchoStr { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Official/EasyAbp.Abp.WeChat.Official/RequestHandling/IWeChatOfficialAppEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Threading.Tasks; | ||
using EasyAbp.Abp.WeChat.Common.Models; | ||
using EasyAbp.Abp.WeChat.Common.RequestHandling.Dtos; | ||
using JetBrains.Annotations; | ||
|
||
namespace EasyAbp.Abp.WeChat.Official.RequestHandling; | ||
|
||
/// <summary> | ||
/// 微信公众号事件通知处理者 | ||
/// </summary> | ||
public interface IWeChatOfficialAppEventHandler | ||
{ | ||
/// <summary> | ||
/// 仅处理回调请求中,相应的 MsgType 值的事件 | ||
/// </summary> | ||
public string MsgType { get; } | ||
|
||
/// <summary> | ||
/// Handler 执行的优先级,值更大的先执行 | ||
/// </summary> | ||
public int Priority { get; } | ||
|
||
/// <summary> | ||
/// 事件处理实现。 | ||
/// </summary> | ||
Task<AppEventHandlingResult> HandleAsync([NotNull] string appId, WeChatAppEventModel model); | ||
} |
10 changes: 10 additions & 0 deletions
10
...ial/EasyAbp.Abp.WeChat.Official/RequestHandling/IWeChatOfficialAppEventHandlerResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
|
||
namespace EasyAbp.Abp.WeChat.Official.RequestHandling; | ||
|
||
public interface IWeChatOfficialAppEventHandlerResolver | ||
{ | ||
Task<List<IWeChatOfficialAppEventHandler>> GetAppEventHandlersAsync([CanBeNull] string msgType); | ||
} |
Oops, something went wrong.