fix problems with notify about count paid users
This commit is contained in:
parent
1584c8c8ef
commit
1827dead7e
@ -364,7 +364,7 @@ public class UserManager
|
||||
|
||||
if (value > 0)
|
||||
{
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
|
||||
return newUserData;
|
||||
@ -668,7 +668,7 @@ public class UserManager
|
||||
return GetUsers(employeeStatus).Where(u => IsUserInGroupInternal(u.Id, groupId, refs)).ToArray();
|
||||
}
|
||||
|
||||
public async Task AddUserIntoGroup(Guid userId, Guid groupId, bool dontClearAddressBook = false)
|
||||
public async Task AddUserIntoGroup(Guid userId, Guid groupId, bool dontClearAddressBook = false, bool notifyWebSocket = true)
|
||||
{
|
||||
if (Constants.LostUser.Id == userId || Constants.LostGroupInfo.ID == groupId)
|
||||
{
|
||||
@ -676,8 +676,8 @@ public class UserManager
|
||||
}
|
||||
|
||||
var user = GetUsers(userId);
|
||||
var isUser = IsUserInGroup(userId, Constants.GroupUser.ID);
|
||||
var userGroups = GetUserGroups(userId);
|
||||
var isUser = this.IsUser(user);
|
||||
var isPaidUser = IsPaidUser(user);
|
||||
|
||||
_permissionContext.DemandPermissions(new UserGroupObject(new UserAccount(user, _tenantManager.GetCurrentTenant().Id, _userFormatter), groupId),
|
||||
Constants.Action_EditGroups);
|
||||
@ -685,6 +685,7 @@ public class UserManager
|
||||
_userService.SaveUserGroupRef(Tenant.Id, new UserGroupRef(userId, groupId, UserGroupRefType.Contains));
|
||||
|
||||
ResetGroupCache(userId);
|
||||
|
||||
if (groupId == Constants.GroupUser.ID)
|
||||
{
|
||||
var tenant = _tenantManager.GetCurrentTenant();
|
||||
@ -698,12 +699,16 @@ public class UserManager
|
||||
}
|
||||
}
|
||||
|
||||
if (!notifyWebSocket)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUser && groupId != Constants.GroupUser.ID ||
|
||||
!isUser && groupId == Constants.GroupUser.ID &&
|
||||
userGroups.Any())
|
||||
!isUser && !isPaidUser && groupId != Constants.GroupUser.ID)
|
||||
{
|
||||
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStat<CountPaidUserFeature, int>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,8 +720,8 @@ public class UserManager
|
||||
}
|
||||
|
||||
var user = GetUsers(userId);
|
||||
var isUser = IsUserInGroup(userId, Constants.GroupUser.ID);
|
||||
var userGroups = GetUserGroups(userId);
|
||||
var isUserBefore = this.IsUser(user);
|
||||
var isPaidUserBefore = IsPaidUser(user);
|
||||
|
||||
_permissionContext.DemandPermissions(new UserGroupObject(new UserAccount(user, _tenantManager.GetCurrentTenant().Id, _userFormatter), groupId),
|
||||
Constants.Action_EditGroups);
|
||||
@ -725,11 +730,14 @@ public class UserManager
|
||||
|
||||
ResetGroupCache(userId);
|
||||
|
||||
if (groupId != Constants.GroupUser.ID &&
|
||||
!isUser && userGroups.Any())
|
||||
var isUserAfter = this.IsUser(user);
|
||||
var isPaidUserAfter = IsPaidUser(user);
|
||||
|
||||
if (isPaidUserBefore && !isPaidUserAfter && isUserAfter ||
|
||||
isUserBefore && !isUserAfter)
|
||||
{
|
||||
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStat<CountPaidUserFeature, int>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -963,7 +971,7 @@ public class UserManager
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return new Group
|
||||
{
|
||||
Id = g.ID,
|
||||
@ -973,4 +981,9 @@ public class UserManager
|
||||
Sid = g.Sid
|
||||
};
|
||||
}
|
||||
|
||||
private bool IsPaidUser(UserInfo userInfo)
|
||||
{
|
||||
return this.IsCollaborator(userInfo) || this.IsDocSpaceAdmin(userInfo);
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ public abstract class BaseStorage : IDataStore
|
||||
{
|
||||
QuotaController.QuotaUsedAdd(Modulename, domain, DataList.GetData(domain), size, quotaCheckFileSize);
|
||||
var(name, value) = await _tenantQuotaFeatureStatHelper.GetStat<MaxTotalSizeFeature, long>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ public abstract class BaseStorage : IDataStore
|
||||
{
|
||||
QuotaController.QuotaUsedDelete(Modulename, domain, DataList.GetData(domain), size);
|
||||
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStat<MaxTotalSizeFeature, long>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
}
|
||||
|
||||
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStat<CountRoomFeature, int>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
|
||||
return room;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
newFolderId = await FolderDao.MoveFolderAsync(folder.Id, toFolderId, CancellationToken);
|
||||
|
||||
var (name, value) = await tenantQuotaFeatureStatHelper.GetStat<CountRoomFeature, int>();
|
||||
await quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
else if (isRoom && toFolder.FolderType == FolderType.Archive)
|
||||
{
|
||||
@ -448,7 +448,7 @@ class FileMoveCopyOperation<T> : FileOperation<FileMoveCopyOperationData<T>, T>
|
||||
newFolderId = await FolderDao.MoveFolderAsync(folder.Id, toFolderId, CancellationToken);
|
||||
|
||||
var (name, value) = await tenantQuotaFeatureStatHelper.GetStat<CountRoomFeature, int>();
|
||||
await quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ public sealed class UserManagerWrapper
|
||||
else if(type == EmployeeType.RoomAdmin)
|
||||
{
|
||||
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStat<CountPaidUserFeature, int>();
|
||||
await _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
_ = _quotaSocketManager.ChangeQuotaUsedValue(name, value);
|
||||
}
|
||||
|
||||
return newUser;
|
||||
@ -272,22 +272,22 @@ public sealed class UserManagerWrapper
|
||||
{
|
||||
if (currentType is EmployeeType.RoomAdmin)
|
||||
{
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID, notifyWebSocket: false);
|
||||
_webItemSecurityCache.ClearCache(Tenant.Id);
|
||||
changed = true;
|
||||
}
|
||||
else if (currentType is EmployeeType.Collaborator)
|
||||
{
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID);
|
||||
await _userManager.RemoveUserFromGroup(user.Id, Constants.GroupCollaborator.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID);
|
||||
_webItemSecurityCache.ClearCache(Tenant.Id);
|
||||
changed = true;
|
||||
}
|
||||
else if (currentType is EmployeeType.User)
|
||||
{
|
||||
await _countPaidUserChecker.CheckAppend();
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID);
|
||||
await _userManager.RemoveUserFromGroup(user.Id, Constants.GroupUser.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupAdmin.ID);
|
||||
_webItemSecurityCache.ClearCache(Tenant.Id);
|
||||
changed = true;
|
||||
}
|
||||
@ -317,8 +317,8 @@ public sealed class UserManagerWrapper
|
||||
else if (type is EmployeeType.Collaborator && currentType is EmployeeType.User)
|
||||
{
|
||||
await _countPaidUserChecker.CheckAppend();
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupCollaborator.ID);
|
||||
await _userManager.RemoveUserFromGroup(user.Id, Constants.GroupUser.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, Constants.GroupCollaborator.ID);
|
||||
_webItemSecurityCache.ClearCache(Tenant.Id);
|
||||
changed = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user