Skip to content

Commit

Permalink
Merge pull request #149 from ONLYOFFICE/bugfix/64971
Browse files Browse the repository at this point in the history
Quota: hide "used" from user
  • Loading branch information
pavelbannov authored Jan 16, 2024
2 parents 3ee1dba + e19da16 commit 602e9ff
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions web/ASC.Web.Api/Core/QuotaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ public class QuotaHelper
private readonly TenantManager _tenantManager;
private readonly IServiceProvider _serviceProvider;
private readonly CoreBaseSettings _coreBaseSettings;

public QuotaHelper(TenantManager tenantManager, IServiceProvider serviceProvider, CoreBaseSettings coreBaseSettings)
private readonly UserManager _userManager;
private readonly AuthContext _authContext;

public QuotaHelper(
TenantManager tenantManager,
IServiceProvider serviceProvider,
CoreBaseSettings coreBaseSettings,
UserManager userManager,
AuthContext authContext)
{
_tenantManager = tenantManager;
_serviceProvider = serviceProvider;
_coreBaseSettings = coreBaseSettings;
_userManager = userManager;
_authContext = authContext;
}

public async IAsyncEnumerable<QuotaDto> GetQuotasAsync()
Expand Down Expand Up @@ -109,7 +118,9 @@ private async IAsyncEnumerable<TenantQuotaFeatureDto> GetFeatures(TenantQuota qu
result.Id = feature.Name;

object used = null;

var currentUserId = _authContext.CurrentAccount.ID;
var isUsedAvailable = !await _userManager.IsUserAsync(currentUserId) && !await _userManager.IsCollaboratorAsync(currentUserId);

if (feature is TenantQuotaFeatureSize size)
{
result.Value = size.Value == long.MaxValue ? -1 : size.Value;
Expand Down Expand Up @@ -137,7 +148,7 @@ private async IAsyncEnumerable<TenantQuotaFeatureDto> GetFeatures(TenantQuota qu
{
result.Used = new FeatureUsedDto
{
Value = used,
Value = isUsedAvailable ? used : null,
Title = Resource.ResourceManager.GetString($"TariffsFeature_used_{feature.Name}")
};
}
Expand Down

0 comments on commit 602e9ff

Please sign in to comment.