From 45339de1982a0280f12280985a92378068f811f2 Mon Sep 17 00:00:00 2001 From: MaksimChegulov Date: Mon, 5 Sep 2022 13:12:40 +0300 Subject: [PATCH 1/4] Files: added gettting shares for rooms --- .../Server/Api/VirtualRoomsController.cs | 80 ++++++++++++++++++- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/products/ASC.Files/Server/Api/VirtualRoomsController.cs b/products/ASC.Files/Server/Api/VirtualRoomsController.cs index 4eb9ace3d1..29e514fd0d 100644 --- a/products/ASC.Files/Server/Api/VirtualRoomsController.cs +++ b/products/ASC.Files/Server/Api/VirtualRoomsController.cs @@ -47,10 +47,29 @@ public class VirtualRoomsInternalController : VirtualRoomsController FileSecurityCommon fileSecurityCommon, EmailValidationKeyProvider emailValidationKeyProvider, FolderDtoHelper folderDtoHelper, - FileDtoHelper fileDtoHelper) : base(foldersControllerHelper, globalFolderHelper, fileOperationDtoHelper, securityControllerHelper, coreBaseSettings, authContext, roomLinksService, customTagsService, roomLogoManager, studioNotifyService, fileStorageService, fileSecurity, fileSecurityCommon, emailValidationKeyProvider, folderDtoHelper, fileDtoHelper) + FileDtoHelper fileDtoHelper, + FileShareDtoHelper fileShareDtoHelper) : base( + foldersControllerHelper, + globalFolderHelper, + fileOperationDtoHelper, + securityControllerHelper, + coreBaseSettings, + authContext, + roomLinksService, + customTagsService, + roomLogoManager, + studioNotifyService, + fileStorageService, + fileSecurity, + fileSecurityCommon, + emailValidationKeyProvider, + folderDtoHelper, + fileDtoHelper, + fileShareDtoHelper) { } + /// /// Create a room in the virtual rooms section /// @@ -95,7 +114,25 @@ public class VirtualRoomsThirdPartyController : VirtualRoomsController FileSecurityCommon fileSecurityCommon, EmailValidationKeyProvider emailValidationKeyProvider, FolderDtoHelper folderDtoHelper, - FileDtoHelper fileDtoHelper) : base(foldersControllerHelper, globalFolderHelper, fileOperationDtoHelper, securityControllerHelper, coreBaseSettings, authContext, roomLinksService, customTagsService, roomLogoManager, studioNotifyService, fileStorageService, fileSecurity, fileSecurityCommon, emailValidationKeyProvider, folderDtoHelper, fileDtoHelper) + FileDtoHelper fileDtoHelper, + FileShareDtoHelper fileShareDtoHelper) : base( + foldersControllerHelper, + globalFolderHelper, + fileOperationDtoHelper, + securityControllerHelper, + coreBaseSettings, + authContext, + roomLinksService, + customTagsService, + roomLogoManager, + studioNotifyService, + fileStorageService, + fileSecurity, + fileSecurityCommon, + emailValidationKeyProvider, + folderDtoHelper, + fileDtoHelper, + fileShareDtoHelper) { } @@ -144,10 +181,26 @@ public abstract class VirtualRoomsController : ApiControllerBase private readonly FileSecurity _fileSecurity; private readonly FileSecurityCommon _fileSecurityCommon; private readonly EmailValidationKeyProvider _emailValidationKeyProvider; + private readonly FileShareDtoHelper _fileShareDtoHelper; - protected VirtualRoomsController(FoldersControllerHelper foldersControllerHelper, GlobalFolderHelper globalFolderHelper, FileOperationDtoHelper fileOperationDtoHelper, SecurityControllerHelper securityControllerHelper, CoreBaseSettings coreBaseSettings, AuthContext authContext, RoomInvitationLinksService roomLinksService, CustomTagsService customTagsService, RoomLogoManager roomLogoManager, StudioNotifyService studioNotifyService, FileStorageService fileStorageService, FileSecurity fileSecurity, FileSecurityCommon fileSecurityCommon, EmailValidationKeyProvider emailValidationKeyProvider, + protected VirtualRoomsController( + FoldersControllerHelper foldersControllerHelper, + GlobalFolderHelper globalFolderHelper, + FileOperationDtoHelper fileOperationDtoHelper, + SecurityControllerHelper securityControllerHelper, + CoreBaseSettings coreBaseSettings, + AuthContext authContext, + RoomInvitationLinksService roomLinksService, + CustomTagsService customTagsService, + RoomLogoManager roomLogoManager, + StudioNotifyService studioNotifyService, + FileStorageService fileStorageService, + FileSecurity fileSecurity, + FileSecurityCommon fileSecurityCommon, + EmailValidationKeyProvider emailValidationKeyProvider, FolderDtoHelper folderDtoHelper, - FileDtoHelper fileDtoHelper) : base(folderDtoHelper, fileDtoHelper) + FileDtoHelper fileDtoHelper, + FileShareDtoHelper fileShareDtoHelper) : base(folderDtoHelper, fileDtoHelper) { _foldersControllerHelper = foldersControllerHelper; _globalFolderHelper = globalFolderHelper; @@ -163,6 +216,7 @@ public abstract class VirtualRoomsController : ApiControllerBase _fileSecurity = fileSecurity; _fileSecurityCommon = fileSecurityCommon; _emailValidationKeyProvider = emailValidationKeyProvider; + _fileShareDtoHelper = fileShareDtoHelper; } /// @@ -354,6 +408,24 @@ public abstract class VirtualRoomsController : ApiControllerBase } } + /// + /// Getting security information about a room + /// + /// + /// Room ID + /// + /// Room security info + [HttpGet("rooms/{id}/share")] + public async IAsyncEnumerable GetRoomSecurityInfo(T id) + { + var fileShares = await _fileStorageService.GetSharedInfoAsync(Array.Empty(), new[] { id }); + + foreach (var fileShareDto in fileShares) + { + yield return await _fileShareDtoHelper.Get(fileShareDto); + } + } + /// /// Getting an invitation link to a virtual room /// From 7bc95a826a539ad7c34f35142f8c14d7b6f87935 Mon Sep 17 00:00:00 2001 From: MaksimChegulov Date: Mon, 5 Sep 2022 13:13:37 +0300 Subject: [PATCH 2/4] Web.Core: changed user profile url --- web/ASC.Web.Core/Utility/CommonLinkUtility.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/ASC.Web.Core/Utility/CommonLinkUtility.cs b/web/ASC.Web.Core/Utility/CommonLinkUtility.cs index d5ec0347e9..c68ac2a640 100644 --- a/web/ASC.Web.Core/Utility/CommonLinkUtility.cs +++ b/web/ASC.Web.Core/Utility/CommonLinkUtility.cs @@ -60,6 +60,8 @@ public class CommonLinkUtility : BaseCommonLinkUtility public const string ParamName_ProductSysName = "product"; public const string ParamName_UserUserID = "uid"; + public const string AbsoluteAccountsPath = "/accounts/"; + public const string VirtualAccountsPath = "~/accounts/"; private readonly UserManager _userManager; private readonly WebItemManagerSecurity _webItemManagerSecurity; @@ -173,7 +175,7 @@ public class CommonLinkUtility : BaseCommonLinkUtility queryParams = guid != Guid.Empty ? GetUserParamsPair(guid) : HttpUtility.UrlEncode(user.ToLowerInvariant()); } - var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/"; + var url = absolute ? ToAbsolute(VirtualAccountsPath) : AbsoluteAccountsPath; url += "view/"; url += queryParams; @@ -184,7 +186,7 @@ public class CommonLinkUtility : BaseCommonLinkUtility { var queryParams = user.Id != Guid.Empty ? GetUserParamsPair(user) : HttpUtility.UrlEncode(user.UserName.ToLowerInvariant()); - var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/"; + var url = absolute ? ToAbsolute(VirtualAccountsPath) : AbsoluteAccountsPath; url += "view/"; url += queryParams; @@ -194,7 +196,7 @@ public class CommonLinkUtility : BaseCommonLinkUtility { var queryParams = GetUserParamsPair(user); - var url = absolute ? ToAbsolute("~/products/people/") : "/products/people/"; + var url = absolute ? ToAbsolute(VirtualAccountsPath) : AbsoluteAccountsPath; url += "view/"; url += queryParams; From 844cc0338cb576b72573103e6489b19e9eb18c87 Mon Sep 17 00:00:00 2001 From: MaksimChegulov Date: Mon, 5 Sep 2022 13:41:11 +0300 Subject: [PATCH 3/4] Files: fix files counter --- products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs index da7a2c81f4..e729493aab 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/AbstractDao.cs @@ -105,7 +105,7 @@ public class AbstractDao using var filesDbContext = _dbContextFactory.CreateDbContext(); var folders = await filesDbContext.Folders .Where(r => r.TenantId == TenantID) - .Where(r => filesDbContext.Tree.Where(r => r.FolderId == folderId).Any(a => r.ParentId == r.Id)) + .Where(r => filesDbContext.Tree.Where(r => r.FolderId == folderId).Any(a => a.ParentId == r.Id)) .ToListAsync(); foreach (var f in folders) From cf88dc82431a6c33c3c48481caaf83a7fca70667 Mon Sep 17 00:00:00 2001 From: MaksimChegulov Date: Mon, 5 Sep 2022 14:27:24 +0300 Subject: [PATCH 4/4] Files: changed to get room information --- .../Server/Api/VirtualRoomsController.cs | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/products/ASC.Files/Server/Api/VirtualRoomsController.cs b/products/ASC.Files/Server/Api/VirtualRoomsController.cs index 29e514fd0d..ee53292a66 100644 --- a/products/ASC.Files/Server/Api/VirtualRoomsController.cs +++ b/products/ASC.Files/Server/Api/VirtualRoomsController.cs @@ -220,41 +220,22 @@ public abstract class VirtualRoomsController : ApiControllerBase } /// - /// Getting the contents of a virtual room + /// Getting virtual room information /// /// /// Room ID /// - /// - /// The value of the beginning of the enumeration - /// - /// - /// Quantity - /// - /// - /// Filter by name - /// - /// - /// User or Group ID - /// - /// - /// Content filtering type - /// - /// - /// Full-text content search - /// - /// - /// Search by subfolders - /// /// - /// Room content + /// Room info /// [HttpGet("rooms/{id}")] - public async Task> GetRoomAsync(T id, Guid? userOrGroupId, FilterType? filterType, bool? searchInContent, bool? withSubFolders) + public async Task> GetRoomInfoAsync(T id) { ErrorIfNotDocSpace(); - return await _foldersControllerHelper.GetFolderAsync(id, userOrGroupId, filterType, searchInContent, withSubFolders); + var folder = await _fileStorageService.GetFolderAsync(id).NotFoundIfNull("Folder not found"); + + return await _folderDtoHelper.GetAsync(folder); } ///