Skip to content

Commit

Permalink
RavenDB-23766 - remove the new version available alert only for the s…
Browse files Browse the repository at this point in the history
…erver store notification storage
  • Loading branch information
grisha-kotler committed Feb 17, 2025
1 parent 14fb531 commit ed11429
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 39 deletions.
39 changes: 1 addition & 38 deletions src/Raven.Server/NotificationCenter/NotificationsStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
}
}
}
}

0 comments on commit ed11429

Please sign in to comment.