diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/Distributed/NotificationEventHandler.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/Distributed/NotificationEventHandler.cs index 29c23b3dc..846c6dbd8 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Handlers/Distributed/NotificationEventHandler.cs +++ b/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(); diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs index 6f97c77a9..f1d6decaa 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessage.cs +++ b/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) diff --git a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs b/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs index 643efbb50..4748c2d4a 100644 --- a/aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.MiniProgram/LINGYUN/Abp/WeChat/MiniProgram/Messages/SubscribeMessager.cs +++ b/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 diff --git a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs b/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs index 209d58a3f..3d68fa762 100644 --- a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Emailing/LINGYUN/Abp/Notifications/Emailing/EmailingNotificationPublishProvider.cs +++ b/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) { diff --git a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs b/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs index 4e4a00de2..84ecb2284 100644 --- a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.WeChat.Work/LINGYUN/Abp/Notifications/WeChat/Work/WeChatWorkNotificationPublishProvider.cs +++ b/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)); diff --git a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs b/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs index e55ca46fc..ed7467f2f 100644 --- a/aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/DefaultNotificationDataSerializer.cs +++ b/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 diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs b/aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs index 804aba971..7be961696 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/EventBus/Distributed/NotificationEventHandler.cs +++ b/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; } diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs index 8253b7b31..f96316056 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs +++ b/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();