diff --git a/products/ASC.Files/Core/Core/Dao/Interfaces/IProviderDao.cs b/products/ASC.Files/Core/Core/Dao/Interfaces/IProviderDao.cs index e4162daf7e..8d5cb9dd49 100644 --- a/products/ASC.Files/Core/Core/Dao/Interfaces/IProviderDao.cs +++ b/products/ASC.Files/Core/Core/Dao/Interfaces/IProviderDao.cs @@ -35,7 +35,7 @@ public interface IProviderDao IAsyncEnumerable GetProvidersInfoAsync(Guid userId); Task SaveProviderInfoAsync(string providerKey, string customerTitle, AuthData authData, FolderType folderType); Task UpdateProviderInfoAsync(int linkId, FolderType rootFolderType); - Task UpdateProviderInfoAsync(int linkId, string folderId, FolderType folderType); + Task UpdateProviderInfoAsync(int linkId, string folderId, FolderType folderType, bool @private); Task UpdateProviderInfoAsync(int linkId, string customerTitle, AuthData authData, FolderType folderType, Guid? userId = null); Task RemoveProviderInfoAsync(int linkId); } diff --git a/products/ASC.Files/Core/Core/FileStorageService.cs b/products/ASC.Files/Core/Core/FileStorageService.cs index 7e77ee24d2..0fc726d932 100644 --- a/products/ASC.Files/Core/Core/FileStorageService.cs +++ b/products/ASC.Files/Core/Core/FileStorageService.cs @@ -424,11 +424,11 @@ public class FileStorageService //: IFileStorageService return InternalCreateNewFolderAsync(parentId, title); } - public async Task> CreateRoomAsync(string title, RoomType roomType, bool privacy, IEnumerable share, bool notify, string sharingMessage) + public async Task> CreateRoomAsync(string title, RoomType roomType, bool @private, IEnumerable share, bool notify, string sharingMessage) { ArgumentNullException.ThrowIfNull(title, nameof(title)); - if (privacy && (share == null || !share.Any())) + if (@private && (share == null || !share.Any())) { throw new ArgumentNullException(nameof(share)); } @@ -437,50 +437,23 @@ public class FileStorageService //: IFileStorageService var room = roomType switch { - RoomType.CustomRoom => await CreateCustomRoomAsync(title, parentId, privacy), - RoomType.FillingFormsRoom => await CreateFillingFormsRoom(title, parentId, privacy), - RoomType.EditingRoom => await CreateEditingRoom(title, parentId, privacy), - RoomType.ReviewRoom => await CreateReviewRoom(title, parentId, privacy), - RoomType.ReadOnlyRoom => await CreateReadOnlyRoom(title, parentId, privacy), - _ => await CreateCustomRoomAsync(title, parentId, privacy), + RoomType.CustomRoom => await CreateCustomRoomAsync(title, parentId, @private), + RoomType.FillingFormsRoom => await CreateFillingFormsRoom(title, parentId, @private), + RoomType.EditingRoom => await CreateEditingRoom(title, parentId, @private), + RoomType.ReviewRoom => await CreateReviewRoom(title, parentId, @private), + RoomType.ReadOnlyRoom => await CreateReadOnlyRoom(title, parentId, @private), + _ => await CreateCustomRoomAsync(title, parentId, @private), }; - if (privacy) + if (@private) { - var list = new List(share.Select(_fileShareParamsHelper.ToAceObject)); - - var admins = _userManager.GetUsersByGroup(Constants.GroupAdmin.ID); - var onlyFilesAdmins = _userManager.GetUsersByGroup(WebItemManager.DocumentsProductID); - - var userInfos = admins.Union(onlyFilesAdmins).ToList(); - - list.AddRange(admins.Select(admin => new AceWrapper - { - Share = FileShare.ReadWrite, - SubjectId = admin.Id - })); - - var advancedSettings = new AceAdvancedSettingsWrapper - { - AllowSharingPrivateRoom = true - }; - - var aceCollection = new AceCollection - { - Folders = new[] { room.Id }, - Files = Array.Empty(), - Aces = list, - Message = sharingMessage, - AdvancedSettings = advancedSettings - }; - - await SetAceObjectAsync(aceCollection, notify); + await SetAcesForPrivateRoomAsync(room, share, notify, sharingMessage); } return room; } - public async Task> CreateThirdPartyRoomAsync(string title, RoomType roomType, T parentId, bool privacy) + public async Task> CreateThirdPartyRoomAsync(string title, RoomType roomType, T parentId, bool @private, IEnumerable share, bool notify, string sharingMessage) { ArgumentNullException.ThrowIfNull(title, nameof(title)); ArgumentNullException.ThrowIfNull(parentId, nameof(parentId)); @@ -503,25 +476,20 @@ public class FileStorageService //: IFileStorageService var room = roomType switch { - RoomType.CustomRoom => await CreateCustomRoomAsync(title, parentId, privacy), - RoomType.FillingFormsRoom => await CreateFillingFormsRoom(title, parentId, privacy), - RoomType.EditingRoom => await CreateEditingRoom(title, parentId, privacy), - RoomType.ReviewRoom => await CreateReviewRoom(title, parentId, privacy), - RoomType.ReadOnlyRoom => await CreateReadOnlyRoom(title, parentId, privacy), - _ => await CreateCustomRoomAsync(title, parentId, privacy), + RoomType.CustomRoom => await CreateCustomRoomAsync(title, parentId, @private), + RoomType.FillingFormsRoom => await CreateFillingFormsRoom(title, parentId, @private), + RoomType.EditingRoom => await CreateEditingRoom(title, parentId, @private), + RoomType.ReviewRoom => await CreateReviewRoom(title, parentId, @private), + RoomType.ReadOnlyRoom => await CreateReadOnlyRoom(title, parentId, @private), + _ => await CreateCustomRoomAsync(title, parentId, @private), }; - var folderType = roomType switch + if (@private) { - RoomType.CustomRoom => FolderType.CustomRoom, - RoomType.ReviewRoom => FolderType.ReviewRoom, - RoomType.EditingRoom => FolderType.EditingRoom, - RoomType.FillingFormsRoom => FolderType.FillingFormsRoom, - RoomType.ReadOnlyRoom => FolderType.ReadOnlyRoom, - _ => FolderType.CustomRoom - }; + await SetAcesForPrivateRoomAsync(room, share, notify, sharingMessage); + } - await providerDao.UpdateProviderInfoAsync(providerInfo.ID, room.Id.ToString(), folderType); + await providerDao.UpdateProviderInfoAsync(providerInfo.ID, room.Id.ToString(), room.FolderType, @private); return room; } @@ -3066,6 +3034,38 @@ public class FileStorageService //: IFileStorageService return string.Empty; } } + + private async Task SetAcesForPrivateRoomAsync(Folder room, IEnumerable share, bool notify, string sharingMessage) + { + var list = new List(share.Select(_fileShareParamsHelper.ToAceObject)); + + var admins = _userManager.GetUsersByGroup(Constants.GroupAdmin.ID); + var onlyFilesAdmins = _userManager.GetUsersByGroup(WebItemManager.DocumentsProductID); + + var userInfos = admins.Union(onlyFilesAdmins).ToList(); + + list.AddRange(admins.Select(admin => new AceWrapper + { + Share = FileShare.ReadWrite, + SubjectId = admin.Id + })); + + var advancedSettings = new AceAdvancedSettingsWrapper + { + AllowSharingPrivateRoom = true + }; + + var aceCollection = new AceCollection + { + Folders = new[] { room.Id }, + Files = Array.Empty(), + Aces = list, + Message = sharingMessage, + AdvancedSettings = advancedSettings + }; + + await SetAceObjectAsync(aceCollection, notify); + } } public class FileModel diff --git a/products/ASC.Files/Core/Core/Thirdparty/ProviderAccountDao.cs b/products/ASC.Files/Core/Core/Thirdparty/ProviderAccountDao.cs index 6a154b5a8d..318ca942e2 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/ProviderAccountDao.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/ProviderAccountDao.cs @@ -224,7 +224,7 @@ internal class ProviderAccountDao : IProviderDao return true; } - public async Task UpdateProviderInfoAsync(int linkId, string folderId, FolderType folderType) + public async Task UpdateProviderInfoAsync(int linkId, string folderId, FolderType folderType, bool @private) { var forUpdate = await FilesDbContext.ThirdpartyAccount .Where(r => r.Id == linkId) @@ -238,6 +238,7 @@ internal class ProviderAccountDao : IProviderDao forUpdate.RoomType = folderType; forUpdate.FolderId = folderId; + forUpdate.Private = @private; await FilesDbContext.SaveChangesAsync().ConfigureAwait(false); diff --git a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileDeleteOperation.cs b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileDeleteOperation.cs index 92d83ea949..38d95ea4f6 100644 --- a/products/ASC.Files/Core/Services/WCFService/FileOperations/FileDeleteOperation.cs +++ b/products/ASC.Files/Core/Services/WCFService/FileOperations/FileDeleteOperation.cs @@ -189,7 +189,7 @@ class FileDeleteOperation : FileOperation, T> { if (folder.ProviderEntry) { - await ProviderDao.UpdateProviderInfoAsync(folder.ProviderId, null, FolderType.DEFAULT); + await ProviderDao.UpdateProviderInfoAsync(folder.ProviderId, null, FolderType.DEFAULT, false); } filesMessageService.Send(folder, _headers, MessageAction.RoomDeleted, folder.Title); diff --git a/products/ASC.Files/Server/Api/VirtualRoomsController.cs b/products/ASC.Files/Server/Api/VirtualRoomsController.cs index b30637576a..5477bb92ce 100644 --- a/products/ASC.Files/Server/Api/VirtualRoomsController.cs +++ b/products/ASC.Files/Server/Api/VirtualRoomsController.cs @@ -90,7 +90,7 @@ public class VirtualRoomsThirdPartyController : VirtualRoomsController { ErrorIfNotDocSpace(); - var room = await _fileStorageService.CreateThirdPartyRoomAsync(inDto.Title, inDto.RoomType, id, inDto.Private); + var room = await _fileStorageService.CreateThirdPartyRoomAsync(inDto.Title, inDto.RoomType, id, inDto.Private, inDto.Share, inDto.Notify, inDto.SharingMessage); return await _folderDtoHelper.GetAsync(room); }