From ed1142999ba97d37ed9daf45b4f221631527f5c5 Mon Sep 17 00:00:00 2001 From: Grisha Kotler Date: Mon, 17 Feb 2025 13:39:46 +0200 Subject: [PATCH] RavenDB-23766 - remove the new version available alert only for the server store notification storage --- .../NotificationsStorage.cs | 39 +--------------- .../ServerStoreNotificationStorage.cs | 45 ++++++++++++++++++- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/Raven.Server/NotificationCenter/NotificationsStorage.cs b/src/Raven.Server/NotificationCenter/NotificationsStorage.cs index d3c9d997b81d..68c378b5467d 100644 --- a/src/Raven.Server/NotificationCenter/NotificationsStorage.cs +++ b/src/Raven.Server/NotificationCenter/NotificationsStorage.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Raven.Client.Util; -using Raven.Server.Json; using Raven.Server.NotificationCenter.Notifications; -using Raven.Server.NotificationCenter.Notifications.Details; using Raven.Server.Rachis.Commands; using Raven.Server.ServerWide; using Raven.Server.ServerWide.Context; @@ -360,9 +358,8 @@ public void ChangePostponeDate(string id, DateTime? postponeUntil) } } - private void Cleanup() + protected virtual void Cleanup() { - RemoveNewVersionAvailableAlertIfNecessary(); } private static string GetTableName(string resourceName) @@ -372,40 +369,6 @@ private static string GetTableName(string resourceName) : $"{Documents.Schemas.Notifications.NotificationsTree}.{resourceName.ToLowerInvariant()}"; } - private void RemoveNewVersionAvailableAlertIfNecessary() - { - var buildNumber = ServerVersion.Build; - - var id = AlertRaised.GetKey(AlertType.Server_NewVersionAvailable, null); - using (Read(id, out var ntv)) - { - using (ntv) - { - if (ntv == null) - return; - - var delete = true; - - if (buildNumber != ServerVersion.DevBuildNumber) - { - if (ntv.Json.TryGetMember(nameof(AlertRaised.Details), out var o) - && o is BlittableJsonReaderObject detailsJson) - { - if (detailsJson.TryGetMember(nameof(NewVersionAvailableDetails.VersionInfo), out o) - && o is BlittableJsonReaderObject newVersionDetailsJson) - { - var value = JsonDeserializationServer.LatestVersionCheckVersionInfo(newVersionDetailsJson); - delete = value.BuildNumber <= buildNumber; - } - } - } - - if (delete) - Delete(id); - } - } - } - [DoesNotReturn] private static void ThrowCouldNotFindNotificationType(NotificationTableValue action) { diff --git a/src/Raven.Server/NotificationCenter/ServerStoreNotificationStorage.cs b/src/Raven.Server/NotificationCenter/ServerStoreNotificationStorage.cs index ca2d752978c2..24273e461b9d 100644 --- a/src/Raven.Server/NotificationCenter/ServerStoreNotificationStorage.cs +++ b/src/Raven.Server/NotificationCenter/ServerStoreNotificationStorage.cs @@ -1,5 +1,9 @@ -using Raven.Server.ServerWide; +using Raven.Server.Json; +using Raven.Server.NotificationCenter.Notifications.Details; +using Raven.Server.NotificationCenter.Notifications; +using Raven.Server.ServerWide; using Raven.Server.ServerWide.Context; +using Sparrow.Json; namespace Raven.Server.NotificationCenter; @@ -14,4 +18,43 @@ protected override void CreateSchema() tx.Commit(); } } + + protected override void Cleanup() + { + RemoveNewVersionAvailableAlertIfNecessary(); + } + + private void RemoveNewVersionAvailableAlertIfNecessary() + { + var buildNumber = ServerVersion.Build; + + var id = AlertRaised.GetKey(AlertType.Server_NewVersionAvailable, null); + using (Read(id, out var ntv)) + { + using (ntv) + { + if (ntv == null) + return; + + var delete = true; + + if (buildNumber != ServerVersion.DevBuildNumber) + { + if (ntv.Json.TryGetMember(nameof(AlertRaised.Details), out var o) + && o is BlittableJsonReaderObject detailsJson) + { + if (detailsJson.TryGetMember(nameof(NewVersionAvailableDetails.VersionInfo), out o) + && o is BlittableJsonReaderObject newVersionDetailsJson) + { + var value = JsonDeserializationServer.LatestVersionCheckVersionInfo(newVersionDetailsJson); + delete = value.BuildNumber <= buildNumber; + } + } + } + + if (delete) + Delete(id); + } + } + } }