From db2c585948cae9913708c58c8e8e2f51615c2896 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 26 Dec 2023 11:18:54 +0300 Subject: [PATCH] fix bug 63733 --- common/ASC.Socket.IO/app/hubs/files.js | 12 ++++++-- .../FileOperations/FileMoveCopyOperation.cs | 19 ++++++------ .../ASC.Files/Core/Utils/SocketManager.cs | 29 +++++++++++++++++-- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/common/ASC.Socket.IO/app/hubs/files.js b/common/ASC.Socket.IO/app/hubs/files.js index fecce5616ce..bcc0aaf4025 100644 --- a/common/ASC.Socket.IO/app/hubs/files.js +++ b/common/ASC.Socket.IO/app/hubs/files.js @@ -146,9 +146,17 @@ modifyFolder(room, "create", fileId, "file", data); } - function createFolder({ folderId, room, data } = {}) { + function createFolder({ folderId, room, data, userIds } = {}) { logger.info(`create new folder ${folderId} in room ${room}`); - modifyFolder(room, "create", folderId, "folder", data); + logger.info(`create new folder length ${userIds.length}`); + if(userIds) + { + userIds.forEach(userId => modifyFolder(`${room}-${userId}`, "create", folderId, "folder", data)); + } + else + { + modifyFolder(room, "create", folderId, "folder", data); + } } function updateFile({ fileId, room, data } = {}) { diff --git a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs index 898b7d2b3a0..213f3bf8f76 100644 --- a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs +++ b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs @@ -116,6 +116,7 @@ private async Task DoAsync(IServiceScope scope, TTo tto) var folderDao = scope.ServiceProvider.GetService>(); var fileSecurity = scope.ServiceProvider.GetService(); var socketManager = scope.ServiceProvider.GetService(); + var userManager = scope.ServiceProvider.GetService(); //TODO: check on each iteration? var toFolder = await folderDao.GetFolderAsync(tto); @@ -211,19 +212,19 @@ private async Task DoAsync(IServiceScope scope, TTo tto) needToMark.AddRange(moveOrCopyFilesTask); - if (toFolder.FolderType != FolderType.Archive) + foreach (var folder in moveOrCopyFoldersTask) { - foreach (var folder in moveOrCopyFoldersTask) + if (toFolder.FolderType != FolderType.Archive && !DocSpaceHelper.IsRoom(folder.FolderType)) { - if (!DocSpaceHelper.IsRoom(folder.FolderType)) - { - needToMark.AddRange(await GetFilesAsync(scope, folder)); - } - - await socketManager.CreateFolderAsync(folder); + needToMark.AddRange(await GetFilesAsync(scope, folder)); } - } + var whoCanRead = await fileSecurity.WhoCanReadAsync(folder); + var admins = await userManager.GetUsers(true, EmployeeStatus.Active, null, null, null, null, null, null, null, true, 0, 0).Select(r=> r.Id).ToListAsync(); + admins.Add(CurrentTenant.OwnerId); + await socketManager.CreateFolderAsync(folder, admins.Concat(whoCanRead).Distinct().ToList()); + } + var ntm = needToMark.Distinct(); foreach (var n in ntm) { diff --git a/products/ASC.Files/Core/Utils/SocketManager.cs b/products/ASC.Files/Core/Utils/SocketManager.cs index 3304a401063..05c33bdacba 100644 --- a/products/ASC.Files/Core/Utils/SocketManager.cs +++ b/products/ASC.Files/Core/Utils/SocketManager.cs @@ -69,13 +69,38 @@ public async Task CreateFileAsync(File file) await MakeRequest("create-file", new { room, fileId = file.Id, data }); } - public async Task CreateFolderAsync(Folder folder) + public async Task CreateFolderAsync(Folder folder, IEnumerable userIds = null) { var room = await GetFolderRoomAsync(folder.ParentId); var data = await SerializeFolder(folder); - await MakeRequest("create-folder", new { room, folderId = folder.Id, data }); + if (userIds.Any()) + { + foreach (var chunk in userIds.Chunk(1000)) + { + await MakeRequest("create-folder", + new + { + room, + folderId = folder.Id, + data, + userIds = chunk + }); + } + + } + else + { + await MakeRequest("create-folder", + new + { + room, + folderId = folder.Id, + data + }); + } + } public async Task UpdateFileAsync(File file)