diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 3a793ef629..f5382846af 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -69,7 +69,7 @@ - + diff --git a/src/ServiceControl.LicenseManagement/LicenseDetails.cs b/src/ServiceControl.LicenseManagement/LicenseDetails.cs index 72f9ca429f..11f6c23ddc 100644 --- a/src/ServiceControl.LicenseManagement/LicenseDetails.cs +++ b/src/ServiceControl.LicenseManagement/LicenseDetails.cs @@ -40,6 +40,8 @@ public class LicenseDetails public LicensedProduct[] Products { get; private init; } + public bool HasEndpointMetadata { get; private init; } + public static LicenseDetails TrialFromEndDate(DateOnly endDate) { return FromLicense(new License @@ -82,6 +84,7 @@ internal static LicenseDetails FromLicense(License license) Edition = license.Edition, //strip any internal prefix from what gets displayed to the customer Products = license.LicensedEndpoints?.Select(le => new LicensedProduct(le.Size.EndsWith("U") ? "Unlimited" : Regex.Replace(le.Size, @"^\D*", ""), le.Quantity)).ToArray(), + HasEndpointMetadata = license.Capabilities.Contains("EndpointMetadataFile"), ValidForServiceControl = license.ValidForApplication("ServiceControl"), DaysUntilSubscriptionExpires = license.GetDaysUntilLicenseExpires(), WarnUserTrialIsExpiring = licenseStatus == LicenseStatus.ValidWithExpiringTrial, diff --git a/src/ServiceControl/Licensing/LicenseController.cs b/src/ServiceControl/Licensing/LicenseController.cs index 51efd95cc3..c86a26ecfe 100644 --- a/src/ServiceControl/Licensing/LicenseController.cs +++ b/src/ServiceControl/Licensing/LicenseController.cs @@ -44,6 +44,7 @@ public async Task> License(bool refresh, string client InstanceName = settings.InstanceName ?? string.Empty, LicenseStatus = activeLicense.Details.Status, Products = activeLicense.Details.Products, + HasEndpointMetadata = activeLicense.Details.HasEndpointMetadata, LicenseExtensionUrl = connectorHeartbeatStatus.LastHeartbeat == null ? $"https://particular.net/extend-your-trial?p={clientName}" : $"https://particular.net/license/mt?p={clientName}&t={(activeLicense.IsEvaluation ? 0 : 1)}" @@ -57,6 +58,11 @@ public async Task> License(bool refresh, string client [Route("license/details")] public async Task> LicenseDetails(CancellationToken cancellationToken) { + if (activeLicense.Details.Edition != "Endpoint Size" || !activeLicense.Details.HasEndpointMetadata) + { + return (LicensedEndpointDetails?)null; + } + var licenseDetails = await dataStore.GetLicensedEndpointDetails(cancellationToken); if (licenseDetails is null) { diff --git a/src/ServiceControl/Licensing/LicenseControllerTypes.cs b/src/ServiceControl/Licensing/LicenseControllerTypes.cs index 5a4a7f9d79..269105165d 100644 --- a/src/ServiceControl/Licensing/LicenseControllerTypes.cs +++ b/src/ServiceControl/Licensing/LicenseControllerTypes.cs @@ -18,6 +18,8 @@ public class LicenseInfo public LicensedProduct[] Products { get; set; } + public bool HasEndpointMetadata { get; set; } + public string LicenseType { get; set; } public string InstanceName { get; set; }