diff --git a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/CosClientFactory.cs b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/CosClientFactory.cs index a65e54ef5..7cc89be2f 100644 --- a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/CosClientFactory.cs +++ b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/LINGYUN/Abp/BlobStoring/Tencent/CosClientFactory.cs @@ -2,10 +2,10 @@ using COSXML.Auth; using LINGYUN.Abp.Tencent; using Microsoft.Extensions.Caching.Memory; +using System; using System.Threading.Tasks; using Volo.Abp.BlobStoring; using Volo.Abp.DependencyInjection; -using Volo.Abp.MultiTenancy; using Volo.Abp.Settings; namespace LINGYUN.Abp.BlobStoring.Tencent; @@ -14,14 +14,14 @@ public class CosClientFactory : AbstractTencentCloudClientFactory(cacheKey); + if (cosXmlCache == null) + { + lock(_clientCacheSync) + { + if (cosXmlCache == null) + { + var configBuilder = new CosXmlConfig.Builder(); + configBuilder + .SetAppid(configuration.AppId) + .SetRegion(configuration.Region); + + var cred = new DefaultQCloudCredentialProvider( + cloudCache.SecretId, + cloudCache.SecretKey, + cloudCache.DurationSecond); + + cosXmlCache = new CosXmlServer(configBuilder.Build(), cred); + + ClientCache.Set( + cacheKey, + cosXmlCache, + // 会话持续时间前60秒过期 + TimeSpan.FromSeconds(cloudCache.DurationSecond - 60)); + } + } + } + + return cosXmlCache; } } diff --git a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs index 7d625425a..2d51eab7c 100644 --- a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs +++ b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/AbstractTencentCloudClientFactory.cs @@ -31,7 +31,7 @@ public abstract class AbstractTencentCloudClientFactory protected async virtual Task GetClientCacheItemAsync() { return await ClientCache.GetOrCreateAsync( - TencentCloudClientCacheItem.CalculateCacheKey("client"), + TencentCloudClientCacheItem.CalculateCacheKey("client-options"), async (_) => { var secretId = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.SecretId); @@ -87,7 +87,7 @@ public abstract class AbstractTencentCloudClientFactory protected async virtual Task GetClientCacheItemAsync() { return await ClientCache.GetOrCreateAsync( - TencentCloudClientCacheItem.CalculateCacheKey("client"), + TencentCloudClientCacheItem.CalculateCacheKey("client-options"), async (_) => { var secretId = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.SecretId); diff --git a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs index 6d9bfd7ba..545deb208 100644 --- a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs +++ b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN/Abp/Tencent/TencentCloudClientFactory.cs @@ -12,9 +12,8 @@ public class TencentCloudClientFactory : AbstractTencentCloudClientFact { public TencentCloudClientFactory( IMemoryCache clientCache, - ICurrentTenant currentTenant, ISettingProvider settingProvider) - : base(clientCache, currentTenant, settingProvider) + : base(clientCache, settingProvider) { } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationContentType.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationContentType.cs new file mode 100644 index 000000000..382fd29f1 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationContentType.cs @@ -0,0 +1,21 @@ +namespace LINGYUN.Abp.Notifications; + +public enum NotificationContentType +{ + /// + /// 文本 + /// + Text = 0, + /// + /// Html + /// + Html = 1, + /// + /// Markdown + /// + Markdown = 2, + /// + /// Json + /// + Json = 3 +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs index 968cd65a3..9e8ee042d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationDefinition.cs @@ -46,6 +46,10 @@ namespace LINGYUN.Abp.Notifications /// 通知类型 /// public NotificationType NotificationType { get; set; } + /// + /// 通知内容类型 + /// + public NotificationContentType ContentType { get; set; } /// /// 通知提供者 /// @@ -66,6 +70,7 @@ namespace LINGYUN.Abp.Notifications ILocalizableString description = null, NotificationType notificationType = NotificationType.Application, NotificationLifetime lifetime = NotificationLifetime.Persistent, + NotificationContentType contentType = NotificationContentType.Text, bool allowSubscriptionToClients = false) { Name = name; @@ -73,6 +78,7 @@ namespace LINGYUN.Abp.Notifications Description = description; NotificationLifetime = lifetime; NotificationType = notificationType; + ContentType = contentType; AllowSubscriptionToClients = allowSubscriptionToClients; Providers = new List(); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs index 5bf588373..a50394c19 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationGroupDefinition.cs @@ -58,6 +58,7 @@ namespace LINGYUN.Abp.Notifications ILocalizableString description = null, NotificationType notificationType = NotificationType.Application, NotificationLifetime lifetime = NotificationLifetime.Persistent, + NotificationContentType contentType = NotificationContentType.Text, bool allowSubscriptionToClients = false) { var notification = new NotificationDefinition( @@ -66,6 +67,7 @@ namespace LINGYUN.Abp.Notifications description, notificationType, lifetime, + contentType, allowSubscriptionToClients ); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationInfo.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationInfo.cs index 2b2f6db31..3ad1a33e5 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationInfo.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationInfo.cs @@ -11,12 +11,14 @@ namespace LINGYUN.Abp.Notifications public DateTime CreationTime { get; set; } public NotificationLifetime Lifetime { get; set; } public NotificationType Type { get; set; } + public NotificationContentType ContentType { get; set; } public NotificationSeverity Severity { get; set; } public NotificationInfo() { Data = new NotificationData(); Lifetime = NotificationLifetime.Persistent; Type = NotificationType.Application; + ContentType = NotificationContentType.Text; Severity = NotificationSeverity.Info; CreationTime = DateTime.Now; diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs index 7bff2a55c..d3288364a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN/Abp/MessageService/Notifications/Dto/NotificationDto.cs @@ -24,5 +24,9 @@ namespace LINGYUN.Abp.MessageService.Notifications /// 通知类型 /// public NotificationType Type { get; set; } + /// + /// 通知内容类型 + /// + public NotificationContentType ContentType { get; set; } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs index c71380dd5..30fefcdd6 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Notifications/NotificationAppService.cs @@ -60,7 +60,8 @@ namespace LINGYUN.Abp.MessageService.Notifications DisplayName = notification.DisplayName.Localize(StringLocalizerFactory), Description = notification.Description?.Localize(StringLocalizerFactory) ?? notification.Name, Lifetime = notification.NotificationLifetime, - Type = notification.NotificationType + Type = notification.NotificationType, + ContentType = notification.ContentType }; notificationGroup.Notifications.Add(notificationChildren); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs index 39846ad48..72932813f 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/MessageServiceDomainAutoMapperProfile.cs @@ -22,6 +22,7 @@ namespace LINGYUN.Abp.MessageService.Mapper .ForMember(dto => dto.Name, map => map.MapFrom(src => src.NotificationName)) .ForMember(dto => dto.Lifetime, map => map.Ignore()) .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) + .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => @@ -41,6 +42,7 @@ namespace LINGYUN.Abp.MessageService.Mapper .ForMember(dto => dto.Name, map => map.MapFrom(src => src.Name)) .ForMember(dto => dto.Lifetime, map => map.Ignore()) .ForMember(dto => dto.Type, map => map.MapFrom(src => src.Type)) + .ForMember(dto => dto.ContentType, map => map.MapFrom(src => src.ContentType)) .ForMember(dto => dto.Severity, map => map.MapFrom(src => src.Severity)) .ForMember(dto => dto.CreationTime, map => map.MapFrom(src => src.CreationTime)) .ForMember(dto => dto.Data, map => map.MapFrom((src, nfi) => diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs index d5b920658..87b4c21c0 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Mapper/NotificationTypeConverter.cs @@ -15,6 +15,7 @@ namespace LINGYUN.Abp.MessageService.Mapper { Name = source.NotificationName, Type = source.Type, + ContentType = source.ContentType, Severity = source.Severity, CreationTime = source.CreationTime, TenantId = source.TenantId diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs index cb217de7d..64b8e9ba4 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/DynamicNotificationDefinitionCache.cs @@ -86,6 +86,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition new FixedLocalizableString(notification.Description), notification.NotificationType, notification.Lifetime, + notification.ContentType, notification.AllowSubscriptionToClients); notificationDefine.Properties.AddIfNotContains(notification.Properties); @@ -117,6 +118,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition new FixedLocalizableString(notification.Description), notification.NotificationType, notification.Lifetime, + notification.ContentType, notification.AllowSubscriptionToClients); notificationDefinition.WithProviders(notification.Providers.ToArray()); @@ -288,6 +290,7 @@ public class DynamicNotificationDefinitionCache : IDynamicNotificationDefinition description, record.NotificationLifetime, record.NotificationType, + record.ContentType, providers, record.AllowSubscriptionToClients); recordCache.Properties.AddIfNotContains(record.ExtraProperties); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs index 41d439853..f6d5e0b45 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/Notification.cs @@ -12,6 +12,7 @@ namespace LINGYUN.Abp.MessageService.Notifications public virtual Guid? TenantId { get; protected set; } public virtual NotificationSeverity Severity { get; protected set; } public virtual NotificationType Type { get; set; } + public virtual NotificationContentType ContentType { get; set; } public virtual long NotificationId { get; protected set; } public virtual string NotificationName { get; protected set; } public virtual string NotificationTypeName { get; protected set; } @@ -43,6 +44,7 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationName = name; NotificationTypeName = dataType; Type = NotificationType.Application; + ContentType = NotificationContentType.Text; TenantId = tenantId; SetData(data); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs index d4539bc70..66419c92e 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionRecord.cs @@ -59,6 +59,10 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP /// public virtual NotificationType NotificationType { get; set; } /// + /// 通知内容类型 + /// + public virtual NotificationContentType ContentType { get; set; } + /// /// 通知提供者 /// /// @@ -86,7 +90,8 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP string resourceName = null, string localization = null, NotificationLifetime lifetime = NotificationLifetime.Persistent, - NotificationType notificationType = NotificationType.Application) + NotificationType notificationType = NotificationType.Application, + NotificationContentType contentType = NotificationContentType.Text) : base(id) { Name = Check.NotNullOrWhiteSpace(name, nameof(name), NotificationDefinitionRecordConsts.MaxNameLength); @@ -95,6 +100,7 @@ public class NotificationDefinitionRecord : BasicAggregateRoot, IHasExtraP Description = Check.Length(description, nameof(description), NotificationDefinitionRecordConsts.MaxDescriptionLength); NotificationLifetime = lifetime; NotificationType = notificationType; + ContentType = contentType; SetLocalization(resourceName, localization); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs index fd2791894..34b941f56 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationDefinitionsCacheItem.cs @@ -38,6 +38,7 @@ public class NotificationDefinitionCacheItem public string Description { get; set; } public NotificationLifetime Lifetime { get; set; } public NotificationType NotificationType { get; set; } + public NotificationContentType ContentType { get; set; } public List Providers { get; set; } public bool AllowSubscriptionToClients { get; set; } public Dictionary Properties { get; set; } @@ -54,6 +55,7 @@ public class NotificationDefinitionCacheItem string description = null, NotificationLifetime lifetime = NotificationLifetime.Persistent, NotificationType notificationType = NotificationType.Application, + NotificationContentType contentType = NotificationContentType.Text, List providers = null, bool allowSubscriptionToClients = false) { @@ -63,6 +65,7 @@ public class NotificationDefinitionCacheItem Description = description; Lifetime = lifetime; NotificationType = notificationType; + ContentType = contentType; Providers = providers ?? new List(); AllowSubscriptionToClients = allowSubscriptionToClients; diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs index 6569071d7..eb9529c27 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs @@ -329,7 +329,7 @@ namespace LINGYUN.Abp.MessageService.Notifications { CreationTime = _clock.Now, Type = notification.Type, - // TODO: 通知过期时间应该可以配置 + ContentType = notification.ContentType, ExpirationTime = _clock.Now.Add(_options.ExpirationTime) }; diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs index 03a7dd28a..1c36f1d4a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/UserNotificationInfo.cs @@ -13,6 +13,7 @@ public class UserNotificationInfo public string NotificationTypeName { get; set; } public DateTime CreationTime { get; set; } public NotificationType Type { get; set; } + public NotificationContentType ContentType { get; set; } public NotificationSeverity Severity { get; set; } public NotificationReadState State { get; set; } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs index c4b1cc3d6..0bd29569d 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContextModelCreatingExtensions.cs @@ -2,6 +2,7 @@ using LINGYUN.Abp.MessageService.Groups; using LINGYUN.Abp.MessageService.Notifications; using LINGYUN.Abp.MessageService.Subscriptions; +using LINGYUN.Abp.Notifications; using Microsoft.EntityFrameworkCore; using System; using Volo.Abp; @@ -29,6 +30,9 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore b.Property(p => p.NotificationTypeName).HasMaxLength(NotificationConsts.MaxTypeNameLength).IsRequired(); //b.Property(p => p.NotificationData).HasMaxLength(NotificationConsts.MaxDataLength).IsRequired(); + b.Property(p => p.ContentType) + .HasDefaultValue(NotificationContentType.Text); + b.ConfigureByConvention(); b.HasIndex(p => new { p.TenantId, p.NotificationName }); @@ -229,6 +233,9 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore b.Property(p => p.Providers) .HasMaxLength(NotificationDefinitionRecordConsts.MaxProvidersLength); + b.Property(p => p.ContentType) + .HasDefaultValue(NotificationContentType.Text); + b.ConfigureByConvention(); }); } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs index e0198d497..e51b9abe4 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs @@ -57,7 +57,8 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationTypeName = n.NotificationTypeName, Severity = n.Severity, State = un.ReadStatus, - Type = n.Type + Type = n.Type, + ContentType = n.ContentType }; return await notifilerQuery @@ -98,7 +99,8 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationTypeName = n.NotificationTypeName, Severity = n.Severity, State = un.ReadStatus, - Type = n.Type + Type = n.Type, + ContentType = n.ContentType }; return await notifilerQuery @@ -166,7 +168,8 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationTypeName = n.NotificationTypeName, Severity = n.Severity, State = un.ReadStatus, - Type = n.Type + Type = n.Type, + ContentType = n.ContentType }; return await notifilerQuery diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs index a2feca472..4cd6b1315 100644 --- a/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.Notifications.PushPlus/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs @@ -1,6 +1,5 @@ using LINGYUN.Abp.PushPlus.Channel; using LINGYUN.Abp.PushPlus.Message; -using System; namespace LINGYUN.Abp.Notifications; public static class NotificationDefinitionExtensions @@ -17,7 +16,7 @@ public static class NotificationDefinitionExtensions /// public static NotificationDefinition WithTemplate( this NotificationDefinition notification, - PushPlusMessageTemplate template = PushPlusMessageTemplate.Text) + PushPlusMessageTemplate template = PushPlusMessageTemplate.Html) { return notification.WithProperty(TemplateKey, template); } @@ -29,7 +28,7 @@ public static class NotificationDefinitionExtensions /// public static PushPlusMessageTemplate GetTemplateOrDefault( this NotificationDefinition notification, - PushPlusMessageTemplate defaultTemplate = PushPlusMessageTemplate.Text) + PushPlusMessageTemplate defaultTemplate = PushPlusMessageTemplate.Html) { if (notification.Properties.TryGetValue(TemplateKey, out var defineTemplate) == true && defineTemplate is PushPlusMessageTemplate template) @@ -37,7 +36,14 @@ public static class NotificationDefinitionExtensions return template; } - return defaultTemplate; + return notification.ContentType switch + { + NotificationContentType.Text => PushPlusMessageTemplate.Text, + NotificationContentType.Html => PushPlusMessageTemplate.Html, + NotificationContentType.Markdown => PushPlusMessageTemplate.Markdown, + NotificationContentType.Json => PushPlusMessageTemplate.Json, + _ => defaultTemplate, + }; } /// /// 设定消息发送通道 diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs index fa11e4645..87d436f83 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.Notifications.WxPusher/LINGYUN/Abp/Notifications/NotificationDefinitionExtensions.cs @@ -37,7 +37,14 @@ public static class NotificationDefinitionExtensions return contentType; } - return defaultContentType; + return notification.ContentType switch + { + NotificationContentType.Text => MessageContentType.Text, + NotificationContentType.Html => MessageContentType.Html, + NotificationContentType.Markdown => MessageContentType.Markdown, + NotificationContentType.Json => MessageContentType.Text, + _ => defaultContentType, + }; } /// /// 消息主题(Topic) 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 f87f4feb0..097fa94d0 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 @@ -194,6 +194,7 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed TenantId = tenantId, Severity = eventData.Severity, Type = notification.NotificationType, + ContentType = notification.ContentType, CreationTime = eventData.CreationTime, Lifetime = notification.NotificationLifetime, }; @@ -282,7 +283,8 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed Severity = eventData.Severity, Lifetime = notification.NotificationLifetime, TenantId = tenantId, - Type = notification.NotificationType + Type = notification.NotificationType, + ContentType = notification.ContentType, }; notificationInfo.SetId(eventData.Id); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.Designer.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.Designer.cs new file mode 100644 index 000000000..c720bf3c2 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.Designer.cs @@ -0,0 +1,735 @@ +// +using System; +using LY.MicroService.RealtimeMessage.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.Migrations +{ + [DbContext(typeof(RealtimeMessageMigrationsDbContext))] + [Migration("20220915102817_Add-ContentType-With-Notification-Definition")] + partial class AddContentTypeWithNotificationDefinition + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Age") + .HasColumnType("int"); + + b.Property("AvatarUrl") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Birthday") + .HasColumnType("datetime(6)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("LastOnlineTime") + .HasColumnType("datetime(6)"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("Sex") + .HasColumnType("int"); + + b.Property("Sign") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Black") + .HasColumnType("tinyint(1)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("DontDisturb") + .HasColumnType("tinyint(1)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("FrientId") + .HasColumnType("char(36)"); + + b.Property("IsStatic") + .HasColumnType("tinyint(1)"); + + b.Property("RemarkName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SpecialFocus") + .HasColumnType("tinyint(1)"); + + b.Property("Status") + .HasColumnType("tinyint unsigned"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "FrientId"); + + b.ToTable("AppUserChatFriends", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AllowAddFriend") + .HasColumnType("tinyint(1)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowReceiveMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("RequireAddFriendValition") + .HasColumnType("tinyint(1)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserChatSettings", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("ReceiveUserId") + .HasColumnType("char(36)"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ReceiveUserId"); + + b.ToTable("AppUserMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Address") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("AdminUserId") + .HasColumnType("char(36)"); + + b.Property("AllowAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("AllowSendMessage") + .HasColumnType("tinyint(1)"); + + b.Property("AvatarUrl") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Description") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("MaxUserCount") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Notice") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Tag") + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "Name"); + + b.ToTable("AppChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("ShieldUserId") + .HasColumnType("char(36)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupChatBlacks", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1048576) + .HasColumnType("longtext"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("MessageId") + .HasColumnType("bigint"); + + b.Property("SendUserName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("State") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId"); + + b.ToTable("AppGroupMessages", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "GroupId", "UserId"); + + b.ToTable("AppUserChatGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasMaxLength(40) + .HasColumnType("varchar(40)") + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("IsAdmin") + .HasColumnType("tinyint(1)"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("char(36)") + .HasColumnName("LastModifierId"); + + b.Property("NickName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("SilenceEnd") + .HasColumnType("datetime(6)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId"); + + b.ToTable("AppUserGroupCards", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("ExpirationTime") + .HasColumnType("datetime(6)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotificationTypeName") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("varchar(512)"); + + b.Property("Severity") + .HasColumnType("tinyint"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "NotificationName"); + + b.ToTable("AppNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionGroupRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitionGroups", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.NotificationDefinitionRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowSubscriptionToClients") + .HasColumnType("tinyint(1)"); + + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("varchar(255)"); + + b.Property("ExtraProperties") + .HasColumnType("longtext") + .HasColumnName("ExtraProperties"); + + b.Property("GroupName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Localization") + .HasMaxLength(128) + .HasColumnType("varchar(128)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("NotificationLifetime") + .HasColumnType("int"); + + b.Property("NotificationType") + .HasColumnType("int"); + + b.Property("Providers") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ResourceName") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.ToTable("AppNotificationDefinitions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Notifications.UserNotification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("NotificationId") + .HasColumnType("bigint"); + + b.Property("ReadStatus") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationId") + .HasDatabaseName("IX_Tenant_User_Notification_Id"); + + b.ToTable("AppUserNotifications", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.MessageService.Subscriptions.UserSubscribe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("NotificationName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasDefaultValue("/"); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "UserId", "NotificationName") + .IsUnique() + .HasDatabaseName("IX_Tenant_User_Notification_Name"); + + b.ToTable("AppUserSubscribes", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.cs new file mode 100644 index 000000000..819cb6c3a --- /dev/null +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/20220915102817_Add-ContentType-With-Notification-Definition.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.RealtimeMessage.Migrations +{ + public partial class AddContentTypeWithNotificationDefinition : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ContentType", + table: "AppNotifications", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContentType", + table: "AppNotificationDefinitions", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ContentType", + table: "AppNotifications"); + + migrationBuilder.DropColumn( + name: "ContentType", + table: "AppNotificationDefinitions"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs index 9718d1bc8..960a067c3 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/Migrations/RealtimeMessageMigrationsDbContextModelSnapshot.cs @@ -519,6 +519,11 @@ namespace LY.MicroService.RealtimeMessage.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + b.Property("CreationTime") .HasColumnType("datetime(6)") .HasColumnName("CreationTime"); @@ -608,6 +613,11 @@ namespace LY.MicroService.RealtimeMessage.Migrations b.Property("AllowSubscriptionToClients") .HasColumnType("tinyint(1)"); + b.Property("ContentType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(0); + b.Property("Description") .HasMaxLength(255) .HasColumnType("varchar(255)"); diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider.cs b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider.cs index 585cb5be1..89e87f50a 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider.cs +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider.cs @@ -16,6 +16,7 @@ group.AddNotification(NotificationsTestsNames.Test3, notificationType: NotificationType.User, + contentType: NotificationContentType.Markdown, lifetime: NotificationLifetime.OnlyOne); } } diff --git a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider_Tests.cs b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider_Tests.cs index 3d453a266..528e5c3ac 100644 --- a/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider_Tests.cs +++ b/aspnet-core/tests/LINGYUN.Abp.Notifications.Tests/LINGYUN/Abp/Notifications/NotificationsTestsDefinitionProvider_Tests.cs @@ -37,7 +37,7 @@ namespace LINGYUN.Abp.Notifications } [Theory] - [InlineData(NotificationsTestsNames.Test1)] + [InlineData(NotificationsTestsNames.Test3)] public async Task Get_Test(string name) { var notification = await NotificationDefinitionManager.GetAsync(name); @@ -46,7 +46,8 @@ namespace LINGYUN.Abp.Notifications notification.Description.ShouldBeNull(); notification.AllowSubscriptionToClients.ShouldBeFalse(); notification.NotificationLifetime.ShouldBe(NotificationLifetime.OnlyOne); - notification.NotificationType.ShouldBe(NotificationType.Application); + notification.NotificationType.ShouldBe(NotificationType.User); + notification.ContentType.ShouldBe(NotificationContentType.Markdown); } } }