From 5501f7e7f1633b394c03cc3e43109c4fa5814fda Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 16 Aug 2024 16:59:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(session):=20=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=AE=A2=E9=98=85=E4=BC=9A=E8=AF=9D=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rSubscribeSessionExpirationEventHandler.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Local/UserSubscribeSessionExpirationEventHandler.cs 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); + } +}