diff --git a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor index c413ec919..b19bae1dc 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/Add.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/Add.razor @@ -65,7 +65,8 @@ notification.ParentId = null; notification.CreatedOn = DateTime.UtcNow; notification.IsDelivered = false; - notification.DeliveredOn = null; + notification.DeliveredOn = null; + notification.SendOn = DateTime.UtcNow; notification = await NotificationService.AddNotificationAsync(notification); await logger.LogInformation("Notification Created {Notification}", notification); NavigationManager.NavigateTo(NavigateUrl()); diff --git a/Oqtane.Client/Modules/Admin/UserProfile/View.razor b/Oqtane.Client/Modules/Admin/UserProfile/View.razor index 2e48fcb1f..32dde145e 100644 --- a/Oqtane.Client/Modules/Admin/UserProfile/View.razor +++ b/Oqtane.Client/Modules/Admin/UserProfile/View.razor @@ -191,7 +191,8 @@ notification.ParentId = notificationid; notification.CreatedOn = DateTime.UtcNow; notification.IsDelivered = false; - notification.DeliveredOn = null; + notification.DeliveredOn = null; + notification.SendOn = DateTime.UtcNow; notification = await NotificationService.AddNotificationAsync(notification); await logger.LogInformation("Notification Created {Notification}", notification); NavigationManager.NavigateTo(NavigateUrl()); diff --git a/Oqtane.Server/Controllers/UserController.cs b/Oqtane.Server/Controllers/UserController.cs index 6fb3c93bd..d27694b41 100644 --- a/Oqtane.Server/Controllers/UserController.cs +++ b/Oqtane.Server/Controllers/UserController.cs @@ -148,7 +148,7 @@ private async Task CreateUser(User user) notification.SiteId = user.SiteId; notification.FromUserId = null; notification.ToUserId = newUser.UserId; - notification.ToEmail = ""; + notification.ToEmail = newUser.Email; notification.Subject = "User Account Verification"; string token = await _identityUserManager.GenerateEmailConfirmationTokenAsync(identityuser); string url = HttpContext.Request.Scheme + "://" + _tenants.GetAlias().Name + "/login?name=" + user.Username + "&token=" + WebUtility.UrlEncode(token); @@ -157,6 +157,7 @@ private async Task CreateUser(User user) notification.CreatedOn = DateTime.UtcNow; notification.IsDelivered = false; notification.DeliveredOn = null; + notification.SendOn = DateTime.UtcNow; _notifications.AddNotification(notification); } @@ -385,6 +386,7 @@ public async Task Forgot([FromBody] User user) notification.CreatedOn = DateTime.UtcNow; notification.IsDelivered = false; notification.DeliveredOn = null; + notification.SendOn = DateTime.UtcNow; _notifications.AddNotification(notification); _logger.Log(LogLevel.Information, this, LogFunction.Security, "Password Reset Notification Sent For {Username}", user.Username); } diff --git a/Oqtane.Server/Oqtane.Server.csproj b/Oqtane.Server/Oqtane.Server.csproj index 0db9ece52..7ae38416c 100644 --- a/Oqtane.Server/Oqtane.Server.csproj +++ b/Oqtane.Server/Oqtane.Server.csproj @@ -22,10 +22,14 @@ + + + + diff --git a/Oqtane.Server/Repository/NotificationRepository.cs b/Oqtane.Server/Repository/NotificationRepository.cs index 4e6550d29..45730d841 100644 --- a/Oqtane.Server/Repository/NotificationRepository.cs +++ b/Oqtane.Server/Repository/NotificationRepository.cs @@ -21,6 +21,7 @@ public IEnumerable GetNotifications(int siteId, int fromUserId, in return _db.Notification .Where(item => item.SiteId == siteId) .Where(item => item.IsDelivered == false) + .Where(item => item.SendOn < System.DateTime.UtcNow) .ToList(); } diff --git a/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql b/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql new file mode 100644 index 000000000..76af104c2 --- /dev/null +++ b/Oqtane.Server/Scripts/Tenant.01.00.01.01.sql @@ -0,0 +1,12 @@ +/* + +Version 1.0.1 Notification migration script + +*/ + +ALTER TABLE [dbo].[Notification] ADD + [SendOn] [datetime] NULL +GO + +UPDATE [dbo].[Notification] SET SendOn = CreatedOn WHERE SendOn IS NULL +GO \ No newline at end of file diff --git a/Oqtane.Shared/Models/Notification.cs b/Oqtane.Shared/Models/Notification.cs index aeb7235da..7ccdbd9d4 100644 --- a/Oqtane.Shared/Models/Notification.cs +++ b/Oqtane.Shared/Models/Notification.cs @@ -22,6 +22,7 @@ public class Notification : IDeletable public string DeletedBy { get; set; } public DateTime? DeletedOn { get; set; } public bool IsDeleted { get; set; } + public DateTime? SendOn { get; set; } } }