Browse Source
Merge pull request #1530 from colinin/fix-wechat-miniprogram-notification-template-data
fix: Fix the data errors in the notification template of the WeChat mini-program
pull/1455/merge
yx lin
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with
24 additions and
4 deletions
aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/Distributed/NotificationEventHandler.cs
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs
aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs
@ -145,6 +145,7 @@ namespace LINGYUN.Abp.MicroService.MessageService.Handlers.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
@ -185,6 +186,7 @@ namespace LINGYUN.Abp.MicroService.MessageService.Handlers.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
var culture = eventData . Data . TryGetData ( NotificationData . CultureKey ) ? . ToString ( ) ;
@ -96,6 +96,7 @@ public class SubscribeMessage
public class MessageData
{
[JsonProperty("value")]
public object Value { get ; }
public MessageData ( object value )
@ -100,7 +100,8 @@ public class SubscribeMessager : ISubscribeMessager, ITransientDependency
{
var client = HttpClientFactory . CreateClient ( AbpWeChatMiniProgramConsts . HttpClient ) ;
var sendDataContent = JsonConvert . SerializeObject ( message ) ;
var requestContent = new StringContent ( sendDataContent ) ;
Logger . LogDebug ( "Send the subscription message request body: {content}" , sendDataContent ) ;
var requestContent = new StringContent ( sendDataContent , Encoding . UTF8 , "application/json" ) ;
var requestMessage = new HttpRequestMessage ( HttpMethod . Post , url )
{
Content = requestContent
@ -52,7 +52,12 @@ public class EmailingNotificationPublishProvider : NotificationPublishProvider
return ;
}
var notificationData = await NotificationDataSerializer . ToStandard ( context . Notification . Data ) ;
if ( notificationData . Title . IsNullOrWhiteSpace ( ) & & notificationData . Message . IsNullOrWhiteSpace ( ) )
{
context . Cancel ( "Unable to send email notifications because the title and content of the message must not be empty." ) ;
Logger . LogWarning ( context . Reason ) ;
return ;
}
// markdown进行处理
if ( context . Notification . ContentType = = NotificationContentType . Markdown )
{
@ -54,6 +54,13 @@ public class WeChatWorkNotificationPublishProvider : NotificationPublishProvider
return ;
}
var notificationData = await NotificationDataSerializer . ToStandard ( context . Notification . Data ) ;
if ( notificationData . Title . IsNullOrWhiteSpace ( ) & & notificationData . Message . IsNullOrWhiteSpace ( ) )
{
context . Cancel ( "Unable to send work weixin messages because the title and content of the message must not be empty." ) ;
Logger . LogWarning ( context . Reason ) ;
return ;
}
var toTag = context . Notification . Data . GetTagOrNull ( ) ? ? notificationDefine ? . GetTagOrNull ( ) ;
var toParty = context . Notification . Data . GetPartyOrNull ( ) ? ? notificationDefine ? . GetPartyOrNull ( ) ;
var toUsers = await WeChatWorkInternalUserFinder . FindUserIdentifierListAsync ( context . Users . Select ( id = > id . UserId ) ) ;
@ -62,8 +62,8 @@ public class DefaultNotificationDataSerializer : INotificationDataSerializer, IS
if ( ! source . NeedLocalizer ( ) )
{
title = source . TryGetData ( "title" ) . ToString ( ) ;
message = source . TryGetData ( "message" ) . ToString ( ) ;
title = source . TryGetData ( "title" ) ? . ToString ( ) ? ? "" ;
message = source . TryGetData ( "message" ) ? . ToString ( ) ? ? "" ;
description = source . TryGetData ( "description" ) ? . ToString ( ) ? ? "" ;
}
else
@ -128,6 +128,7 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
@ -167,6 +168,7 @@ namespace LY.MicroService.Applications.Single.EventBus.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
@ -145,6 +145,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
@ -185,6 +186,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed
var notification = await NotificationDefinitionManager . GetOrNullAsync ( eventData . Name ) ;
if ( notification = = null )
{
Logger . LogWarning ( "Notification definition {notificationName} is not registered in the message service. Subscription message cannot be sent!" , eventData . Name ) ;
return ;
}
var culture = eventData . Data . TryGetData ( NotificationData . CultureKey ) ? . ToString ( ) ;