diff --git a/common/ASC.Core.Common/GlobalUsings.cs b/common/ASC.Core.Common/GlobalUsings.cs index b9192094cc..80989c1451 100644 --- a/common/ASC.Core.Common/GlobalUsings.cs +++ b/common/ASC.Core.Common/GlobalUsings.cs @@ -54,7 +54,6 @@ global using Amazon.SimpleEmail; global using Amazon.SimpleEmail.Model; global using ASC.Api.Core.Extensions; -global using ASC.Api.Core.Extensions; global using ASC.AuditTrail.Models; global using ASC.Collections; global using ASC.Common; diff --git a/common/ASC.EventBus.RabbitMQ/EventBusRabbitMQ.cs b/common/ASC.EventBus.RabbitMQ/EventBusRabbitMQ.cs index f986c7e0a3..8a3a1d06d7 100644 --- a/common/ASC.EventBus.RabbitMQ/EventBusRabbitMQ.cs +++ b/common/ASC.EventBus.RabbitMQ/EventBusRabbitMQ.cs @@ -90,7 +90,7 @@ private async Task SubsManager_OnEventRemovedAsync(object sender, string eventNa await _persistentConnection.TryConnectAsync(); } - using var channel = await _persistentConnection.CreateModelAsync(); + await using var channel = await _persistentConnection.CreateModelAsync(); await channel.QueueUnbindAsync(queue: _queueName, exchange: EXCHANGE_NAME, @@ -124,7 +124,7 @@ public async Task PublishAsync(IntegrationEvent @event) _logger.TraceCreatingRabbitMQChannel(@event.Id, eventName); - using var channel = await _persistentConnection.CreateModelAsync(); + await using var channel = await _persistentConnection.CreateModelAsync(); _logger.TraceDeclaringRabbitMQChannel(@event.Id); diff --git a/common/ASC.MessagingSystem/Core/HistorySocketManager.cs b/common/ASC.MessagingSystem/Core/HistorySocketManager.cs index b0c877a794..28e269294c 100644 --- a/common/ASC.MessagingSystem/Core/HistorySocketManager.cs +++ b/common/ASC.MessagingSystem/Core/HistorySocketManager.cs @@ -58,11 +58,6 @@ await MakeRequest( ); } } - - public void UpdateHistory(int tenantId, IEnumerable auditReference) - { - UpdateHistoryAsync(tenantId, auditReference).GetAwaiter().GetResult(); - } private static string GetRoom(int tenantId, int entryId, int entryType) { diff --git a/common/ASC.MessagingSystem/Core/MessageFactory.cs b/common/ASC.MessagingSystem/Core/MessageFactory.cs index f9dfffcfe8..2f165201d6 100644 --- a/common/ASC.MessagingSystem/Core/MessageFactory.cs +++ b/common/ASC.MessagingSystem/Core/MessageFactory.cs @@ -27,13 +27,13 @@ namespace ASC.MessagingSystem.Core; [Scope] -public class MessageFactory(AuthContext authContext, - TenantManager tenantManager, - ILogger logger, - IHttpContextAccessor httpContextAccessor) +public class MessageFactory( + AuthContext authContext, + TenantManager tenantManager, + ILogger logger, + IHttpContextAccessor httpContextAccessor) { - public EventMessage Create(HttpRequest request, string initiator, DateTime? dateTime, MessageAction action, MessageTarget target, - IEnumerable references = null, params string[] description) + public EventMessage Create(HttpRequest request, string initiator, DateTime? dateTime, MessageAction action, MessageTarget target, IEnumerable references = null, params string[] description) { try { @@ -60,8 +60,7 @@ public EventMessage Create(HttpRequest request, string initiator, DateTime? date } } - public EventMessage Create(IDictionary headers, MessageAction action, MessageTarget target, - IEnumerable references = null, params string[] description) + public EventMessage Create(IDictionary headers, MessageAction action, MessageTarget target, IEnumerable references = null, params string[] description) { try { @@ -101,28 +100,6 @@ public EventMessage Create(IDictionary headers, MessageAct } } - public EventMessage Create(string initiator, MessageAction action, MessageTarget target, params string[] description) - { - try - { - return new EventMessage - { - Initiator = initiator, - Date = DateTime.UtcNow, - TenantId = tenantManager.GetCurrentTenantId(), - Action = action, - Description = description, - Target = target, - }; - } - catch (Exception ex) - { - logger.ErrorWhileParseInitiatorMessage(action, ex); - - return null; - } - } - public EventMessage Create(HttpRequest request, MessageUserData userData, MessageAction action) { try diff --git a/common/ASC.Migration/Migrators/Migrator.cs b/common/ASC.Migration/Migrators/Migrator.cs index 98c2444cb3..f8fd214744 100644 --- a/common/ASC.Migration/Migrators/Migrator.cs +++ b/common/ASC.Migration/Migrators/Migrator.cs @@ -44,27 +44,27 @@ public abstract class Migrator( UserManagerWrapper userManagerWrapper) : IAsyncDisposable { - protected SecurityContext SecurityContext { get; } = securityContext; + private SecurityContext SecurityContext { get; } = securityContext; protected UserManager UserManager { get; } = userManager; - protected TenantQuotaFeatureStatHelper TenantQuotaFeatureStatHelper { get; } = tenantQuotaFeatureStatHelper; - protected QuotaSocketManager QuotaSocketManager { get; } = quotaSocketManager; - protected FileStorageService FileStorageService { get; } = fileStorageService; - protected GlobalFolderHelper GlobalFolderHelper { get; } = globalFolderHelper; - protected IServiceProvider ServiceProvider { get; } = serviceProvider; - protected IDaoFactory DaoFactory { get; } = daoFactory; - protected EntryManager EntryManager { get; } = entryManager; + private TenantQuotaFeatureStatHelper TenantQuotaFeatureStatHelper { get; } = tenantQuotaFeatureStatHelper; + private QuotaSocketManager QuotaSocketManager { get; } = quotaSocketManager; + private FileStorageService FileStorageService { get; } = fileStorageService; + private GlobalFolderHelper GlobalFolderHelper { get; } = globalFolderHelper; + private IServiceProvider ServiceProvider { get; } = serviceProvider; + private IDaoFactory DaoFactory { get; } = daoFactory; + private EntryManager EntryManager { get; } = entryManager; protected MigrationLogger MigrationLogger { get; } = migrationLogger; - protected AuthContext AuthContext { get; } = authContext; + private AuthContext AuthContext { get; } = authContext; protected DisplayUserSettingsHelper DisplayUserSettingsHelper { get; } = displayUserSettingsHelper; - protected UserManagerWrapper UserManagerWrapper { get; } = userManagerWrapper; + private UserManagerWrapper UserManagerWrapper { get; } = userManagerWrapper; - public MigrationInfo MigrationInfo { get; set; } - protected IAccount _currentUser; + public MigrationInfo MigrationInfo { get; protected init; } + private IAccount _currentUser; private Dictionary _usersForImport; - protected List _importedUsers; - protected List _failedUsers; - protected readonly string _folderKey = "folder"; - protected readonly string _fileKey = "file"; + private List _importedUsers; + private List _failedUsers; + private const string FolderKey = "folder"; + private const string FileKey = "file"; protected double _lastProgressUpdate; protected string _lastStatusUpdate; @@ -332,12 +332,12 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u newFolder.Id = -1; } - matchingFilesIds.Add($"{_folderKey}-{storage.RootKey}", newFolder); + matchingFilesIds.Add($"{FolderKey}-{storage.RootKey}", newFolder); var orderedFolders = storage.Folders.OrderBy(f => f.Level); foreach (var folder in orderedFolders) { if (!storage.ShouldImportSharedFolders || - !storage.Securities.Any(s => s.EntryId == folder.Id && s.EntryType == 1) && matchingFilesIds[$"{_folderKey}-{folder.ParentId}"].Id != 0) + !storage.Securities.Any(s => s.EntryId == folder.Id && s.EntryType == 1) && matchingFilesIds[$"{FolderKey}-{folder.ParentId}"].Id != 0) { if (storage.Type == FolderType.BUNCH && !folder.Private) { @@ -345,7 +345,7 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u } else { - newFolder = await FileStorageService.CreateFolderAsync(matchingFilesIds[$"{_folderKey}-{folder.ParentId}"].Id, folder.Title); + newFolder = await FileStorageService.CreateFolderAsync(matchingFilesIds[$"{FolderKey}-{folder.ParentId}"].Id, folder.Title); } Log(string.Format(MigrationResource.CreateFolder, newFolder.Title)); @@ -355,7 +355,7 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u newFolder = ServiceProvider.GetService>(); newFolder.Title = folder.Title; } - matchingFilesIds.Add($"{_folderKey}-{folder.Id}", newFolder); + matchingFilesIds.Add($"{FolderKey}-{folder.Id}", newFolder); } var fileDao = DaoFactory.GetFileDao(); @@ -367,7 +367,7 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u await using var fs = new FileStream(file.Path, FileMode.Open); var newFile = ServiceProvider.GetService>(); - newFile.ParentId = matchingFilesIds[$"{_folderKey}-{file.Folder}"].Id; + newFile.ParentId = matchingFilesIds[$"{FolderKey}-{file.Folder}"].Id; newFile.Comment = FilesCommonResource.CommentCreate; newFile.Title = Path.GetFileName(file.Title); newFile.ContentLength = fs.Length; @@ -376,18 +376,18 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u newFile.Comment = file.Comment; newFile.CreateOn = file.Created; newFile.ModifiedOn = file.Modified; - if (matchingFilesIds.ContainsKey($"{_fileKey}-{file.Id}")) + if (matchingFilesIds.ContainsKey($"{FileKey}-{file.Id}")) { - newFile.Id = matchingFilesIds[$"{_fileKey}-{file.Id}"].Id; + newFile.Id = matchingFilesIds[$"{FileKey}-{file.Id}"].Id; } if (!storage.ShouldImportSharedFolders || !storage.Securities.Any(s => s.EntryId == file.Folder && s.EntryType == 1) && newFile.ParentId != 0) { newFile = await fileDao.SaveFileAsync(newFile, fs); Log(string.Format(MigrationResource.CreateFile, file.Title)); } - if (!matchingFilesIds.ContainsKey($"{_fileKey}-{file.Id}") && newFile.Id != 0) + if (!matchingFilesIds.ContainsKey($"{FileKey}-{file.Id}") && newFile.Id != 0) { - matchingFilesIds.Add($"{_fileKey}-{file.Id}", newFile); + matchingFilesIds.Add($"{FileKey}-{file.Id}", newFile); } } catch (Exception ex) @@ -419,7 +419,7 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u var entryIsFile = security.EntryType == 2; if (entryIsFile && storage.ShouldImportSharedFiles) { - var key = $"{_fileKey}-{security.EntryId}"; + var key = $"{FileKey}-{security.EntryId}"; if(!matchingFilesIds.ContainsKey(key)) { continue; @@ -478,7 +478,7 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u else if (storage.ShouldImportSharedFolders) { var localMatchingRoomIds = new Dictionary>(); - var key = $"{_folderKey}-{security.EntryId}"; + var key = $"{FolderKey}-{security.EntryId}"; if (innerFolders.Contains(security.EntryId)) { @@ -551,15 +551,15 @@ private async Task MigrateStorageAsync(MigrationStorage storage, MigrationUser u newFile.VersionGroup = file.VersionGroup; newFile.CreateOn = file.Created; newFile.ModifiedOn = file.Modified; - if (matchingFilesIds.ContainsKey($"{_fileKey}-{file.Id}")) + if (matchingFilesIds.ContainsKey($"{FileKey}-{file.Id}")) { - newFile.Id = matchingFilesIds[$"{_fileKey}-{file.Id}"].Id; + newFile.Id = matchingFilesIds[$"{FileKey}-{file.Id}"].Id; } newFile = await fileDao.SaveFileAsync(newFile, fs); Log(string.Format(MigrationResource.CreateFile, file.Title)); - if (!matchingFilesIds.ContainsKey($"{_fileKey}-{file.Id}")) + if (!matchingFilesIds.ContainsKey($"{FileKey}-{file.Id}")) { - matchingFilesIds.Add($"{_fileKey}-{file.Id}", newFile); + matchingFilesIds.Add($"{FileKey}-{file.Id}", newFile); } } catch(Exception ex) diff --git a/common/ASC.Migration/Migrators/Provider/WorkspaceMigrator.cs b/common/ASC.Migration/Migrators/Provider/WorkspaceMigrator.cs index 734ffe1a11..1d3a7e1468 100644 --- a/common/ASC.Migration/Migrators/Provider/WorkspaceMigrator.cs +++ b/common/ASC.Migration/Migrators/Provider/WorkspaceMigrator.cs @@ -206,7 +206,7 @@ private void ParseAndUnionStorage(MigrationStorage newStorage, MigrationStorage destinationStorage.Folders = destinationStorage.Folders.Union(newStorage.Folders).ToList(); } - public async Task ParseUsersAsync(bool reportProgress, int count) + private async Task ParseUsersAsync(bool reportProgress, int count) { await using var stream = _dataReader.GetEntry("databases/core/core_user"); var data = new DataTable(); @@ -307,7 +307,7 @@ public async Task ParseUsersAsync(bool reportProgress, int count) } } - public void ParseStorage(MigrationStorage storage, string createBy = "") + private void ParseStorage(MigrationStorage storage, string createBy = "") { //docker unzip filesfolder_... instend of files/folder... var folderFiles = _dataReader.GetDirectories("").Select(Path.GetFileName).FirstOrDefault(d => d.StartsWith("files")); @@ -553,7 +553,7 @@ private void DbExtractFilesSecurity(MigrationStorage storage, string createBy) } } - public void ParseGroup() + private void ParseGroup() { using var streamGroup = _dataReader.GetEntry("databases/core/core_group"); var dataGroup = new DataTable(); diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs index 49ab2933ec..2e41d9fb49 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs @@ -1096,7 +1096,7 @@ public async Task IsSharedAsync(FileEntry entry, IEnumerable( private string _key = string.Empty; private FileReferenceData _referenceData; public string GetFileType(File file) => file.ConvertedExtension.Trim('.'); - public InfoConfig Info { get; set; } = infoConfig; + public InfoConfig Info { get; } = infoConfig; public bool IsLinkedForMe { get; set; } public string Key diff --git a/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs b/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs index 378bb83516..b5f4ce42ae 100644 --- a/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs +++ b/products/ASC.Files/Server/Helpers/FilesControllerHelper.cs @@ -41,7 +41,6 @@ public class FilesControllerHelper(IServiceProvider serviceProvider, FileConverter fileConverter, PathProvider pathProvider, FileChecker fileChecker, - IDistributedCache distributedCache, FillingFormResultDtoHelper fillingFormResultDtoHelper) : FilesHelperBase(filesSettingsHelper, fileUploader, @@ -49,8 +48,7 @@ public class FilesControllerHelper(IServiceProvider serviceProvider, fileDtoHelper, fileStorageService, fileChecker, - httpContextAccessor, - distributedCache) + httpContextAccessor) { private readonly ILogger _logger = logger; diff --git a/products/ASC.Files/Server/Helpers/FilesHelperBase.cs b/products/ASC.Files/Server/Helpers/FilesHelperBase.cs index 1dffb99293..0eeec1202c 100644 --- a/products/ASC.Files/Server/Helpers/FilesHelperBase.cs +++ b/products/ASC.Files/Server/Helpers/FilesHelperBase.cs @@ -33,14 +33,12 @@ public abstract class FilesHelperBase( FileDtoHelper fileDtoHelper, FileStorageService fileStorageService, FileChecker fileChecker, - IHttpContextAccessor httpContextAccessor, - IDistributedCache distributedCache) + IHttpContextAccessor httpContextAccessor) { protected readonly FilesSettingsHelper _filesSettingsHelper = filesSettingsHelper; protected readonly FileUploader _fileUploader = fileUploader; protected readonly FileDtoHelper _fileDtoHelper = fileDtoHelper; protected readonly FileStorageService _fileStorageService = fileStorageService; - protected readonly IDistributedCache _distributedCache = distributedCache; protected readonly FileChecker _fileChecker = fileChecker; protected readonly IHttpContextAccessor _httpContextAccessor = httpContextAccessor; diff --git a/products/ASC.Files/Server/Helpers/SecurityControllerHelper.cs b/products/ASC.Files/Server/Helpers/SecurityControllerHelper.cs index 6f07b54877..df02e6a361 100644 --- a/products/ASC.Files/Server/Helpers/SecurityControllerHelper.cs +++ b/products/ASC.Files/Server/Helpers/SecurityControllerHelper.cs @@ -36,8 +36,7 @@ public class SecurityControllerHelper( IHttpContextAccessor httpContextAccessor, FileShareDtoHelper fileShareDtoHelper, FileShareParamsHelper fileShareParamsHelper, - FileChecker fileChecker, - IDistributedCache distributedCache) + FileChecker fileChecker) : FilesHelperBase( filesSettingsHelper, fileUploader, @@ -45,17 +44,16 @@ public class SecurityControllerHelper( fileDtoHelper, fileStorageService, fileChecker, - httpContextAccessor, - distributedCache) + httpContextAccessor) { public IAsyncEnumerable GetFileSecurityInfoAsync(T fileId) { - return GetSecurityInfoAsync(new List { fileId }, new List()); + return GetSecurityInfoAsync(new List { fileId }, []); } public IAsyncEnumerable GetFolderSecurityInfoAsync(T folderId) { - return GetSecurityInfoAsync(new List(), new List { folderId }); + return GetSecurityInfoAsync([], new List { folderId }); } public async IAsyncEnumerable GetSecurityInfoAsync(IEnumerable fileIds, IEnumerable folderIds) @@ -75,11 +73,6 @@ public async Task RemoveSecurityInfoAsync(List fileIds, List fold return true; } - public IAsyncEnumerable SetFolderSecurityInfoAsync(T folderId, IEnumerable share, bool notify, string sharingMessage) - { - return SetSecurityInfoAsync(new List(), new List { folderId }, share, notify, sharingMessage); - } - public async IAsyncEnumerable SetSecurityInfoAsync(IEnumerable fileIds, IEnumerable folderIds, IEnumerable share, bool notify, string sharingMessage) { if (share != null && share.Any()) diff --git a/products/ASC.Files/Server/Helpers/UploadControllerHelper.cs b/products/ASC.Files/Server/Helpers/UploadControllerHelper.cs index f7fc7c0934..419e61b015 100644 --- a/products/ASC.Files/Server/Helpers/UploadControllerHelper.cs +++ b/products/ASC.Files/Server/Helpers/UploadControllerHelper.cs @@ -41,8 +41,7 @@ public class UploadControllerHelper( SecurityContext securityContext, IDaoFactory daoFactory, FileSecurity fileSecurity, - FileChecker fileChecker, - IDistributedCache distributedCache) + FileChecker fileChecker) : FilesHelperBase( filesSettingsHelper, fileUploader, @@ -50,8 +49,7 @@ public class UploadControllerHelper( fileDtoHelper, fileStorageService, fileChecker, - httpContextAccessor, - distributedCache) + httpContextAccessor) { public async Task CreateEditSessionAsync(T fileId, long fileSize) {