mirror of
https://github.com/bitwarden/server.git
synced 2026-01-31 14:13:18 +08:00
[PM-30626] Fetch provided storage from Pricing Service when determining storage limit (#6845)
* Fetch provided storage from Pricing Service * Run dotnet format * Gbubemi's feedback
This commit is contained in:
@@ -6,6 +6,7 @@ using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies;
|
||||
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.PolicyRequirements;
|
||||
using Bit.Core.AdminConsole.Services;
|
||||
using Bit.Core.Billing.Pricing;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Repositories;
|
||||
@@ -27,6 +28,7 @@ public class SendValidationService : ISendValidationService
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly ICurrentContext _currentContext;
|
||||
private readonly IPolicyRequirementQuery _policyRequirementQuery;
|
||||
private readonly IPricingClient _pricingClient;
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +40,7 @@ public class SendValidationService : ISendValidationService
|
||||
IUserService userService,
|
||||
IPolicyRequirementQuery policyRequirementQuery,
|
||||
GlobalSettings globalSettings,
|
||||
|
||||
IPricingClient pricingClient,
|
||||
ICurrentContext currentContext)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
@@ -48,6 +50,7 @@ public class SendValidationService : ISendValidationService
|
||||
_userService = userService;
|
||||
_policyRequirementQuery = policyRequirementQuery;
|
||||
_globalSettings = globalSettings;
|
||||
_pricingClient = pricingClient;
|
||||
_currentContext = currentContext;
|
||||
}
|
||||
|
||||
@@ -123,10 +126,19 @@ public class SendValidationService : ISendValidationService
|
||||
}
|
||||
else
|
||||
{
|
||||
// Users that get access to file storage/premium from their organization get the default
|
||||
// 1 GB max storage.
|
||||
short limit = _globalSettings.SelfHosted ? Constants.SelfHostedMaxStorageGb : (short)1;
|
||||
storageBytesRemaining = user.StorageBytesRemaining(limit);
|
||||
// Users that get access to file storage/premium from their organization get storage
|
||||
// based on the current premium plan from the pricing service
|
||||
short provided;
|
||||
if (_globalSettings.SelfHosted)
|
||||
{
|
||||
provided = Constants.SelfHostedMaxStorageGb;
|
||||
}
|
||||
else
|
||||
{
|
||||
var premiumPlan = await _pricingClient.GetAvailablePremiumPlan();
|
||||
provided = (short)premiumPlan.Storage.Provided;
|
||||
}
|
||||
storageBytesRemaining = user.StorageBytesRemaining(provided);
|
||||
}
|
||||
}
|
||||
else if (send.OrganizationId.HasValue)
|
||||
|
||||
Reference in New Issue
Block a user