Skip to content

Commit

Permalink
fix bug 63733
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbannov committed Dec 26, 2023
1 parent c605e9e commit db2c585
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
12 changes: 10 additions & 2 deletions common/ASC.Socket.IO/app/hubs/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private async Task DoAsync<TTo>(IServiceScope scope, TTo tto)
var folderDao = scope.ServiceProvider.GetService<IFolderDao<TTo>>();
var fileSecurity = scope.ServiceProvider.GetService<FileSecurity>();
var socketManager = scope.ServiceProvider.GetService<SocketManager>();
var userManager = scope.ServiceProvider.GetService<UserManager>();

//TODO: check on each iteration?
var toFolder = await folderDao.GetFolderAsync(tto);
Expand Down Expand Up @@ -211,19 +212,19 @@ private async Task DoAsync<TTo>(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)
{
Expand Down
29 changes: 27 additions & 2 deletions products/ASC.Files/Core/Utils/SocketManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,38 @@ public async Task CreateFileAsync<T>(File<T> file)
await MakeRequest("create-file", new { room, fileId = file.Id, data });
}

public async Task CreateFolderAsync<T>(Folder<T> folder)
public async Task CreateFolderAsync<T>(Folder<T> folder, IEnumerable<Guid> 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<T>(File<T> file)
Expand Down

0 comments on commit db2c585

Please sign in to comment.