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
parent
commit
03332d262e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/Distributed/NotificationEventHandler.cs
  2. 1
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs
  3. 3
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs
  4. 7
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs
  5. 7
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs
  6. 4
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs
  7. 2
      aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs
  8. 2
      aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs

2
aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/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();

1
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs

@ -96,6 +96,7 @@ public class SubscribeMessage
public class MessageData
{
[JsonProperty("value")]
public object Value { get; }
public MessageData(object value)

3
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs

@ -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

7
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs

@ -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)
{

7
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs

@ -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));

4
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs

@ -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

2
aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs

@ -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;
}

2
aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs

@ -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();

Loading…
Cancel
Save