diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserSubscribeSessionExpirationEventHandler.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserSubscribeSessionExpirationEventHandler.cs new file mode 100644 index 000000000..870805fba --- /dev/null +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserSubscribeSessionExpirationEventHandler.cs @@ -0,0 +1,28 @@ +using LINGYUN.Abp.Identity.Notifications; +using LINGYUN.Abp.Notifications; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities.Events; +using Volo.Abp.EventBus; +using Volo.Abp.Users; + +namespace LY.MicroService.RealtimeMessage.EventBus; + +public class UserSubscribeSessionExpirationEventHandler : ILocalEventHandler>, ITransientDependency +{ + private readonly INotificationSubscriptionManager _notificationSubscriptionManager; + + public UserSubscribeSessionExpirationEventHandler(INotificationSubscriptionManager notificationSubscriptionManager) + { + _notificationSubscriptionManager = notificationSubscriptionManager; + } + + public async virtual Task HandleEventAsync(EntityCreatedEventData eventData) + { + await _notificationSubscriptionManager + .SubscribeAsync( + eventData.Entity.TenantId, + new UserIdentifier(eventData.Entity.Id, eventData.Entity.UserName), + IdentityNotificationNames.Session.ExpirationSession); + } +}