From 5740b578db245fe9ba0cc6a98bd212c9f4dd92d6 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Mon, 19 Sep 2022 18:20:21 +0300 Subject: [PATCH] Payment: rename --- .../Billing/License/LicenseReader.cs | 2 +- common/ASC.Core.Common/Tenants/TenantQuota.cs | 4 ++-- products/ASC.People/Server/Api/UserController.cs | 16 +++++++--------- web/ASC.Web.Api/Api/PortalController.cs | 2 +- .../Api/Settings/LicenseController.cs | 2 +- .../ApiModels/ResponseDto/QuotaUsageDto.cs | 2 +- web/ASC.Web.Core/Utility/TenantExtra.cs | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/common/ASC.Core.Common/Billing/License/LicenseReader.cs b/common/ASC.Core.Common/Billing/License/LicenseReader.cs index f8a188e2e9..08ff011552 100644 --- a/common/ASC.Core.Common/Billing/License/LicenseReader.cs +++ b/common/ASC.Core.Common/Billing/License/LicenseReader.cs @@ -198,7 +198,7 @@ public class LicenseReader var quota = new TenantQuota(-1000) { - ActiveUsers = _constants.MaxEveryoneCount, + CountUser = _constants.MaxEveryoneCount, MaxFileSize = defaultQuota.MaxFileSize, MaxTotalSize = defaultQuota.MaxTotalSize, Name = "license", diff --git a/common/ASC.Core.Common/Tenants/TenantQuota.cs b/common/ASC.Core.Common/Tenants/TenantQuota.cs index 27015773c7..a1544f9d00 100644 --- a/common/ASC.Core.Common/Tenants/TenantQuota.cs +++ b/common/ASC.Core.Common/Tenants/TenantQuota.cs @@ -34,7 +34,7 @@ public class TenantQuota : IMapFrom Name = "Default", MaxFileSize = 25 * 1024 * 1024, // 25Mb MaxTotalSize = long.MaxValue, - ActiveUsers = int.MaxValue, + CountUser = int.MaxValue, CountManager = int.MaxValue, CountRoom = int.MaxValue }; @@ -84,7 +84,7 @@ public class TenantQuota : IMapFrom } private readonly CountUserFeature _countUserFeature; - public int ActiveUsers + public int CountUser { get => _countUserFeature.Value; set => _countUserFeature.Value = value; diff --git a/products/ASC.People/Server/Api/UserController.cs b/products/ASC.People/Server/Api/UserController.cs index f027b41eaf..d22db9a2c5 100644 --- a/products/ASC.People/Server/Api/UserController.cs +++ b/products/ASC.People/Server/Api/UserController.cs @@ -32,7 +32,6 @@ public class UserController : PeopleControllerBase private readonly ICache _cache; private readonly TenantManager _tenantManager; - private readonly Constants _constants; private readonly CookiesManager _cookiesManager; private readonly CoreBaseSettings _coreBaseSettings; private readonly CustomNamingPeople _customNamingPeople; @@ -61,12 +60,11 @@ public class UserController : PeopleControllerBase private readonly IDaoFactory _daoFactory; private readonly EmailValidationKeyProvider _validationKeyProvider; private readonly CountManagerChecker _countManagerChecker; - private readonly CountUserChecker _activeUsersChecker; + private readonly CountUserChecker _countUserChecker; public UserController( ICache cache, TenantManager tenantManager, - Constants constants, CookiesManager cookiesManager, CoreBaseSettings coreBaseSettings, CustomNamingPeople customNamingPeople, @@ -105,8 +103,7 @@ public class UserController : PeopleControllerBase : base(userManager, permissionContext, apiContext, userPhotoManager, httpClientFactory, httpContextAccessor) { _cache = cache; - _tenantManager = tenantManager; - _constants = constants; + _tenantManager = tenantManager; _cookiesManager = cookiesManager; _coreBaseSettings = coreBaseSettings; _customNamingPeople = customNamingPeople; @@ -135,7 +132,7 @@ public class UserController : PeopleControllerBase _daoFactory = daoFactory; _validationKeyProvider = validationKeyProvider; _countManagerChecker = countManagerChecker; - _activeUsersChecker = activeUsersChecker; + _countUserChecker = activeUsersChecker; } [HttpPost("active")] @@ -966,7 +963,8 @@ public class UserController : PeopleControllerBase var canBeGuestFlag = !user.IsOwner(Tenant) && !_userManager.IsAdmin(user) && user.GetListAdminModules(_webItemSecurity, _webItemManager).Count == 0 && !user.IsMe(_authContext); if (inDto.IsVisitor && !_userManager.IsVisitor(user) && canBeGuestFlag) - { + { + await _countUserChecker.CheckUsed(); _userManager.AddUserIntoGroup(user.Id, Constants.GroupUser.ID); _webItemSecurityCache.ClearCache(Tenant.Id); } @@ -1017,7 +1015,7 @@ public class UserController : PeopleControllerBase } else { - await _activeUsersChecker.CheckUsed(); + await _countUserChecker.CheckUsed(); } user.Status = EmployeeStatus.Active; @@ -1066,7 +1064,7 @@ public class UserController : PeopleControllerBase _webItemSecurityCache.ClearCache(Tenant.Id); break; case EmployeeType.Visitor: - await _activeUsersChecker.CheckUsed(); + await _countUserChecker.CheckUsed(); _userManager.AddUserIntoGroup(user.Id, Constants.GroupUser.ID); _webItemSecurityCache.ClearCache(Tenant.Id); break; diff --git a/web/ASC.Web.Api/Api/PortalController.cs b/web/ASC.Web.Api/Api/PortalController.cs index a0404ea36c..cbc27f04b8 100644 --- a/web/ASC.Web.Api/Api/PortalController.cs +++ b/web/ASC.Web.Api/Api/PortalController.cs @@ -215,7 +215,7 @@ public class PortalController : ControllerBase return _tenantManager.GetTenantQuotas().OrderBy(r => r.Price) .FirstOrDefault(quota => - quota.ActiveUsers > needUsersCount + quota.CountUser > needUsersCount && quota.MaxTotalSize > usedSpace); } diff --git a/web/ASC.Web.Api/Api/Settings/LicenseController.cs b/web/ASC.Web.Api/Api/Settings/LicenseController.cs index 430efaede2..e776565041 100644 --- a/web/ASC.Web.Api/Api/Settings/LicenseController.cs +++ b/web/ASC.Web.Api/Api/Settings/LicenseController.cs @@ -155,7 +155,7 @@ public class LicenseController : BaseSettingsController var quota = new TenantQuota(-1000) { Name = "apirequest", - ActiveUsers = curQuota.ActiveUsers, + CountUser = curQuota.CountUser, MaxFileSize = curQuota.MaxFileSize, MaxTotalSize = curQuota.MaxTotalSize, Features = curQuota.Features diff --git a/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaUsageDto.cs b/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaUsageDto.cs index c757cd8cfd..3e1b6da707 100644 --- a/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaUsageDto.cs +++ b/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaUsageDto.cs @@ -77,7 +77,7 @@ public class QuotaUsageManager UsedSize = (ulong)Math.Max(0, quotaRows.Sum(r => r.Counter)), MaxUsersCount = quota.CountManager, UsersCount = _coreBaseSettings.Personal ? 1 : await _countManagerStatistic.GetValue(), - MaxVisitors = _coreBaseSettings.Standalone ? -1 : quota.ActiveUsers, + MaxVisitors = _coreBaseSettings.Standalone ? -1 : quota.CountUser, VisitorsCount = _coreBaseSettings.Personal ? 0 : await _activeUsersStatistic.GetValue(), StorageUsage = quotaRows diff --git a/web/ASC.Web.Core/Utility/TenantExtra.cs b/web/ASC.Web.Core/Utility/TenantExtra.cs index bea626013f..a56529adb6 100644 --- a/web/ASC.Web.Core/Utility/TenantExtra.cs +++ b/web/ASC.Web.Core/Utility/TenantExtra.cs @@ -138,9 +138,9 @@ public class TenantExtra var needUsersCount = await _countManagerStatistic.GetValue(); var quotas = GetTenantQuotas(); - return quotas.OrderBy(q => q.ActiveUsers) + return quotas.OrderBy(q => q.CountUser) .FirstOrDefault(q => - q.ActiveUsers > needUsersCount + q.CountUser > needUsersCount && q.MaxTotalSize > usedSpace && !q.Free && !q.Trial);