2022-04-10 12:30:46 +00:00
|
|
|
|
// (c) Copyright Ascensio System SIA 2010-2022
|
|
|
|
|
//
|
|
|
|
|
// This program is a free software product.
|
|
|
|
|
// You can redistribute it and/or modify it under the terms
|
|
|
|
|
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
|
|
|
|
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
|
|
|
|
|
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
|
|
|
|
|
// any third-party rights.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
|
|
|
|
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
|
|
|
|
|
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
|
//
|
|
|
|
|
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
|
|
|
|
//
|
|
|
|
|
// The interactive user interfaces in modified source and object code versions of the Program must
|
|
|
|
|
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
|
|
|
|
//
|
|
|
|
|
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
|
|
|
|
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
|
|
|
|
// trademark law for use of our trademarks.
|
|
|
|
|
//
|
|
|
|
|
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
|
|
|
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
|
|
|
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
|
|
|
|
|
|
namespace ASC.Files.Api;
|
|
|
|
|
|
|
|
|
|
[ConstraintRoute("int")]
|
2022-05-29 19:36:28 +00:00
|
|
|
|
public class VirtualRoomsInternalController : VirtualRoomsController<int>
|
2022-04-10 12:30:46 +00:00
|
|
|
|
{
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public VirtualRoomsInternalController(FoldersControllerHelper<int> foldersControllerHelper, GlobalFolderHelper globalFolderHelper, FileOperationDtoHelper fileOperationDtoHelper, SecurityControllerHelper<int> securityControllerHelper, CoreBaseSettings coreBaseSettings, AuthContext authContext, RoomLinksService roomLinksManager, CustomTagsService<int> customTagsService, RoomLogoManager roomLogoManager, FileStorageService<int> fileStorageService, FolderDtoHelper folderDtoHelper) : base(foldersControllerHelper, globalFolderHelper, fileOperationDtoHelper, securityControllerHelper, coreBaseSettings, authContext, roomLinksManager, customTagsService, roomLogoManager, fileStorageService, folderDtoHelper)
|
2022-05-29 19:36:28 +00:00
|
|
|
|
{
|
2022-05-31 13:49:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPost("rooms")]
|
2022-05-31 13:49:54 +00:00
|
|
|
|
public async Task<FolderDto<int>> CreateRoomAsync(CreateRoomRequestDto inDto)
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _fileStorageService.CreateRoomAsync(inDto.Title, inDto.RoomType);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
2022-05-29 19:36:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VirtualRoomsThirdpartyController : VirtualRoomsController<string>
|
|
|
|
|
{
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public VirtualRoomsThirdpartyController(FoldersControllerHelper<string> foldersControllerHelper, GlobalFolderHelper globalFolderHelper, FileOperationDtoHelper fileOperationDtoHelper, SecurityControllerHelper<string> securityControllerHelper, CoreBaseSettings coreBaseSettings, AuthContext authContext, RoomLinksService roomLinksManager, CustomTagsService<string> customTagsService, RoomLogoManager roomLogoManager, FileStorageService<string> fileStorageService, FolderDtoHelper folderDtoHelper) : base(foldersControllerHelper, globalFolderHelper, fileOperationDtoHelper, securityControllerHelper, coreBaseSettings, authContext, roomLinksManager, customTagsService, roomLogoManager, fileStorageService, folderDtoHelper)
|
2022-04-10 12:30:46 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
2022-05-30 11:31:30 +00:00
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPost("rooms/thirdparty/{id}")]
|
2022-05-31 13:49:54 +00:00
|
|
|
|
public async Task<FolderDto<string>> CreateRoomAsync(string id, CreateRoomRequestDto inDto)
|
2022-05-30 11:31:30 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _fileStorageService.CreateThirdpartyRoomAsync(inDto.Title, inDto.RoomType, id);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
2022-04-10 12:30:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 07:33:59 +00:00
|
|
|
|
public abstract class VirtualRoomsController<T> : ApiControllerBase
|
2022-04-10 12:30:46 +00:00
|
|
|
|
{
|
2022-04-12 07:33:59 +00:00
|
|
|
|
private readonly FoldersControllerHelper<T> _foldersControllerHelper;
|
2022-04-10 12:30:46 +00:00
|
|
|
|
private readonly GlobalFolderHelper _globalFolderHelper;
|
2022-04-13 13:01:50 +00:00
|
|
|
|
private readonly FileOperationDtoHelper _fileOperationDtoHelper;
|
2022-04-18 21:05:52 +00:00
|
|
|
|
private readonly SecurityControllerHelper<T> _securityControllerHelper;
|
2022-04-20 08:26:31 +00:00
|
|
|
|
private readonly CoreBaseSettings _coreBaseSettings;
|
2022-05-05 12:31:04 +00:00
|
|
|
|
private readonly AuthContext _authContext;
|
2022-05-13 16:25:28 +00:00
|
|
|
|
private readonly RoomLinksService _roomLinksManager;
|
2022-05-20 16:26:13 +00:00
|
|
|
|
private readonly CustomTagsService<T> _customTagsService;
|
2022-06-02 18:41:16 +00:00
|
|
|
|
private readonly RoomLogoManager _roomLogoManager;
|
2022-05-30 11:31:30 +00:00
|
|
|
|
protected readonly FileStorageService<T> _fileStorageService;
|
|
|
|
|
protected readonly FolderDtoHelper _folderDtoHelper;
|
2022-04-10 12:30:46 +00:00
|
|
|
|
|
2022-06-02 18:41:16 +00:00
|
|
|
|
protected VirtualRoomsController(FoldersControllerHelper<T> foldersControllerHelper, GlobalFolderHelper globalFolderHelper, FileOperationDtoHelper fileOperationDtoHelper, SecurityControllerHelper<T> securityControllerHelper, CoreBaseSettings coreBaseSettings, AuthContext authContext, RoomLinksService roomLinksManager, CustomTagsService<T> customTagsService, RoomLogoManager roomLogoManager, FileStorageService<T> fileStorageService, FolderDtoHelper folderDtoHelper)
|
2022-04-10 12:30:46 +00:00
|
|
|
|
{
|
2022-04-12 07:33:59 +00:00
|
|
|
|
_foldersControllerHelper = foldersControllerHelper;
|
2022-05-29 19:36:28 +00:00
|
|
|
|
_globalFolderHelper = globalFolderHelper;
|
2022-04-13 13:01:50 +00:00
|
|
|
|
_fileOperationDtoHelper = fileOperationDtoHelper;
|
2022-04-18 21:05:52 +00:00
|
|
|
|
_securityControllerHelper = securityControllerHelper;
|
2022-04-20 08:26:31 +00:00
|
|
|
|
_coreBaseSettings = coreBaseSettings;
|
2022-05-05 12:31:04 +00:00
|
|
|
|
_authContext = authContext;
|
|
|
|
|
_roomLinksManager = roomLinksManager;
|
2022-05-20 16:26:13 +00:00
|
|
|
|
_customTagsService = customTagsService;
|
2022-06-02 18:41:16 +00:00
|
|
|
|
_roomLogoManager = roomLogoManager;
|
|
|
|
|
_fileStorageService = fileStorageService;
|
|
|
|
|
_folderDtoHelper = folderDtoHelper;
|
2022-04-10 12:30:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpGet("rooms/{id}")]
|
2022-04-28 13:00:05 +00:00
|
|
|
|
public async Task<FolderContentDto<T>> GetRoomAsync(T id, Guid userOrGroupId, FilterType filterType, bool searchInContent, bool withSubFolders)
|
2022-04-13 14:25:12 +00:00
|
|
|
|
{
|
2022-04-20 08:26:31 +00:00
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-04-28 13:00:05 +00:00
|
|
|
|
return await _foldersControllerHelper.GetFolderAsync(id, userOrGroupId, filterType, searchInContent, withSubFolders);
|
2022-04-24 21:08:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public async Task<FolderDto<T>> UpdateRoomAsync(T id, UpdateRoomRequestDto inDto)
|
2022-04-24 21:08:01 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _fileStorageService.FolderRenameAsync(id, inDto.Title);
|
2022-04-13 14:25:12 +00:00
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpDelete("rooms/{id}")]
|
2022-04-24 21:08:01 +00:00
|
|
|
|
public async Task<FileOperationDto> DeleteRoomAsync(T id)
|
2022-04-13 13:01:50 +00:00
|
|
|
|
{
|
2022-04-20 08:26:31 +00:00
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
var operationResult = _fileStorageService.DeleteFolder("delete", id, false, true, true)
|
|
|
|
|
.FirstOrDefault();
|
2022-04-13 13:01:50 +00:00
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
return await _fileOperationDtoHelper.GetAsync(operationResult);
|
2022-04-13 13:01:50 +00:00
|
|
|
|
}
|
2022-04-15 14:22:44 +00:00
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/archive")]
|
2022-04-24 21:08:01 +00:00
|
|
|
|
public async Task<FileOperationDto> ArchiveRoomAsync(T id)
|
2022-04-15 14:22:44 +00:00
|
|
|
|
{
|
2022-04-20 08:26:31 +00:00
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-04-15 14:22:44 +00:00
|
|
|
|
var destFolder = JsonSerializer.SerializeToElement(await _globalFolderHelper.FolderArchiveAsync);
|
2022-04-24 21:08:01 +00:00
|
|
|
|
var movableRoom = JsonSerializer.SerializeToElement(id);
|
2022-04-15 14:22:44 +00:00
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
var operationResult = _fileStorageService.MoveOrCopyItems(new List<JsonElement> { movableRoom }, new List<JsonElement>(), destFolder, FileConflictResolveType.Skip, false, true)
|
|
|
|
|
.FirstOrDefault();
|
2022-04-15 14:22:44 +00:00
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
return await _fileOperationDtoHelper.GetAsync(operationResult);
|
2022-04-15 14:22:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/unarchive")]
|
2022-04-24 21:08:01 +00:00
|
|
|
|
public async Task<FileOperationDto> UnarchiveRoomAsync(T id)
|
2022-04-15 14:22:44 +00:00
|
|
|
|
{
|
2022-04-20 08:26:31 +00:00
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-04-15 14:22:44 +00:00
|
|
|
|
var destFolder = JsonSerializer.SerializeToElement(await _globalFolderHelper.FolderVirtualRoomsAsync);
|
2022-04-24 21:08:01 +00:00
|
|
|
|
var movableRoom = JsonSerializer.SerializeToElement(id);
|
2022-04-15 14:22:44 +00:00
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
var operationResult = _fileStorageService.MoveOrCopyItems(new List<JsonElement> { movableRoom }, new List<JsonElement>(), destFolder, FileConflictResolveType.Skip, false, true)
|
|
|
|
|
.FirstOrDefault();
|
2022-04-15 14:22:44 +00:00
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
return await _fileOperationDtoHelper.GetAsync(operationResult);
|
2022-04-15 14:22:44 +00:00
|
|
|
|
}
|
2022-04-20 08:26:31 +00:00
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/share")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public Task<IEnumerable<FileShareDto>> SetRoomSecurityAsync(T id, SecurityInfoRequestDto inDto)
|
2022-04-22 08:33:08 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-04-24 21:08:01 +00:00
|
|
|
|
return _securityControllerHelper.SetFolderSecurityInfoAsync(id, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
2022-04-22 08:33:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpGet("rooms/{id}/invite")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public object GetInvitationLink(T id, InviteUserRequestDto inDto)
|
2022-05-05 12:31:04 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-05-13 16:25:28 +00:00
|
|
|
|
return _roomLinksManager.GenerateLink(id, inDto.Email, (int)inDto.Access, inDto.EmployeeType, _authContext.CurrentAccount.ID);
|
2022-05-05 12:31:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/tags")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public async Task<FolderDto<T>> AddTagsAsync(T id, BatchTagsRequestDto inDto)
|
2022-05-20 16:26:13 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-05-26 11:43:56 +00:00
|
|
|
|
var room = await _customTagsService.AddRoomTagsAsync(id, inDto.TagIds);
|
2022-05-20 16:26:13 +00:00
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpDelete("rooms/{id}/tags")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public async Task<FolderDto<T>> DeleteTagsAsync(T id, BatchTagsRequestDto inDto)
|
2022-05-20 16:26:13 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-05-26 11:43:56 +00:00
|
|
|
|
var room = await _customTagsService.DeleteRoomTagsAsync(id, inDto.TagIds);
|
2022-05-20 16:26:13 +00:00
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPost("rooms/{id}/logo")]
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public async Task<FolderDto<T>> CreateRoomLogoAsync(T id, LogoRequestDto inDto)
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _roomLogoManager.CreateAsync(id, inDto.TmpFile, inDto.X, inDto.Y, inDto.Width, inDto.Height);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpDelete("rooms/{id}/logo")]
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public async Task<FolderDto<T>> DeleteRoomLogoAsync(T id)
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _roomLogoManager.DeleteAsync(id);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/pin")]
|
2022-06-07 16:07:55 +00:00
|
|
|
|
public async Task<FolderDto<T>> PinRoomAsync(T id)
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _fileStorageService.SetPinnedStatusAsync(id, true);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPut("rooms/{id}/unpin")]
|
2022-06-07 16:07:55 +00:00
|
|
|
|
public async Task<FolderDto<T>> UnpinRoomAsync(T id)
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var room = await _fileStorageService.SetPinnedStatusAsync(id, false);
|
|
|
|
|
|
|
|
|
|
return await _folderDtoHelper.GetAsync(room);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-30 11:31:30 +00:00
|
|
|
|
protected void ErrorIfNotDocSpace()
|
2022-05-29 19:36:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (_coreBaseSettings.DisableDocSpace)
|
|
|
|
|
{
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VirtualRoomsCommonController : ApiControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly FileStorageService<int> _fileStorageService;
|
|
|
|
|
private readonly FolderContentDtoHelper _folderContentDtoHelper;
|
|
|
|
|
private readonly GlobalFolderHelper _globalFolderHelper;
|
|
|
|
|
private readonly CoreBaseSettings _coreBaseSettings;
|
|
|
|
|
private readonly ApiContext _apiContext;
|
|
|
|
|
private readonly CustomTagsService<int> _customTagsService;
|
2022-06-02 18:41:16 +00:00
|
|
|
|
private readonly RoomLogoManager _roomLogoManager;
|
|
|
|
|
private readonly SetupInfo _setupInfo;
|
|
|
|
|
private readonly FileSizeComment _fileSizeComment;
|
2022-05-29 19:36:28 +00:00
|
|
|
|
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public VirtualRoomsCommonController(FileStorageService<int> fileStorageService, FolderContentDtoHelper folderContentDtoHelper, GlobalFolderHelper globalFolderHelper, CoreBaseSettings coreBaseSettings, ApiContext apiContext, CustomTagsService<int> customTagsService, RoomLogoManager roomLogoManager, SetupInfo setupInfo, FileSizeComment fileSizeComment)
|
2022-05-29 19:36:28 +00:00
|
|
|
|
{
|
|
|
|
|
_fileStorageService = fileStorageService;
|
|
|
|
|
_folderContentDtoHelper = folderContentDtoHelper;
|
|
|
|
|
_globalFolderHelper = globalFolderHelper;
|
|
|
|
|
_coreBaseSettings = coreBaseSettings;
|
|
|
|
|
_apiContext = apiContext;
|
|
|
|
|
_customTagsService = customTagsService;
|
2022-06-02 18:41:16 +00:00
|
|
|
|
_roomLogoManager = roomLogoManager;
|
|
|
|
|
_setupInfo = setupInfo;
|
|
|
|
|
_fileSizeComment = fileSizeComment;
|
2022-05-29 19:36:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpGet("rooms")]
|
2022-06-09 17:11:12 +00:00
|
|
|
|
public async Task<FolderContentDto<int>> GetRoomsFolderAsync(string types, string subjectId, bool searchInContent, bool withSubfolders, SearchArea searchArea, string tags)
|
2022-05-29 19:36:28 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
var parentId = await _globalFolderHelper.GetFolderVirtualRooms<int>();
|
|
|
|
|
|
2022-06-09 17:11:12 +00:00
|
|
|
|
var roomTypes = !string.IsNullOrEmpty(types) ? JsonSerializer.Deserialize <IEnumerable<RoomType>>(types) : null;
|
|
|
|
|
|
|
|
|
|
var filterTypes = roomTypes != null ? roomTypes.Select(t => t switch
|
2022-05-29 19:36:28 +00:00
|
|
|
|
{
|
2022-06-09 17:11:12 +00:00
|
|
|
|
RoomType.FillingFormsRoom => FilterType.FillingFormsRooms,
|
|
|
|
|
RoomType.ReadOnlyRoom => FilterType.ReadOnlyRooms,
|
|
|
|
|
RoomType.EditingRoom => FilterType.EditingRooms,
|
|
|
|
|
RoomType.ReviewRoom => FilterType.ReviewRooms,
|
|
|
|
|
RoomType.CustomRoom => FilterType.CustomRooms,
|
2022-05-29 19:36:28 +00:00
|
|
|
|
_ => FilterType.None
|
2022-06-09 17:11:12 +00:00
|
|
|
|
}) : new[] { FilterType.None };
|
2022-05-29 19:36:28 +00:00
|
|
|
|
|
|
|
|
|
var tagIds = !string.IsNullOrEmpty(tags) ? JsonSerializer.Deserialize<IEnumerable<int>>(tags) : null;
|
|
|
|
|
|
|
|
|
|
OrderBy orderBy = null;
|
|
|
|
|
if (Enum.TryParse(_apiContext.SortBy, true, out SortedByType sortBy))
|
|
|
|
|
{
|
|
|
|
|
orderBy = new OrderBy(sortBy, !_apiContext.SortDescending);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var startIndex = Convert.ToInt32(_apiContext.StartIndex);
|
|
|
|
|
var count = Convert.ToInt32(_apiContext.Count);
|
|
|
|
|
var filterValue = _apiContext.FilterValue;
|
|
|
|
|
|
2022-06-09 17:11:12 +00:00
|
|
|
|
var content = await _fileStorageService.GetFolderItemsAsync(parentId, startIndex, count, filterTypes, false, subjectId, filterValue, searchInContent, withSubfolders, orderBy, searchArea, tagIds);
|
2022-05-29 19:36:28 +00:00
|
|
|
|
|
|
|
|
|
var dto = await _folderContentDtoHelper.GetAsync(content, startIndex);
|
|
|
|
|
|
|
|
|
|
return dto.NotFoundIfNull();
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPost("tags")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public async Task<TagInfo> CreateTagAsync(CreateTagRequestDto inDto)
|
2022-05-20 16:26:13 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
return await _customTagsService.CreateTagAsync(inDto.Name);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpGet("tags")]
|
2022-05-20 16:26:13 +00:00
|
|
|
|
public async IAsyncEnumerable<TagInfo> GetTagsInfoAsync()
|
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
2022-05-26 13:37:31 +00:00
|
|
|
|
var from = Convert.ToInt32(_apiContext.StartIndex);
|
|
|
|
|
var count = Convert.ToInt32(_apiContext.Count);
|
2022-05-20 16:26:13 +00:00
|
|
|
|
|
2022-05-26 13:37:31 +00:00
|
|
|
|
await foreach (var tag in _customTagsService.GetTagsInfoAsync(_apiContext.FilterValue, TagType.Custom, from, count))
|
2022-05-20 16:26:13 +00:00
|
|
|
|
{
|
|
|
|
|
yield return tag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpDelete("tags")]
|
2022-05-26 11:43:56 +00:00
|
|
|
|
public async Task DeleteTagsAsync(BatchTagsRequestDto inDto)
|
2022-05-23 09:25:33 +00:00
|
|
|
|
{
|
|
|
|
|
ErrorIfNotDocSpace();
|
|
|
|
|
|
|
|
|
|
await _customTagsService.DeleteTagsAsync(inDto.TagIds);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 13:38:34 +00:00
|
|
|
|
[HttpPost("logos")]
|
2022-06-02 18:41:16 +00:00
|
|
|
|
public async Task<UploadResultDto> UploadRoomLogo(IFormCollection formCollection)
|
|
|
|
|
{
|
|
|
|
|
var result = new UploadResultDto();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (formCollection.Files.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var roomLogo = formCollection.Files[0];
|
|
|
|
|
|
|
|
|
|
if (roomLogo.Length > _setupInfo.MaxImageUploadSize)
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = _fileSizeComment.FileImageSizeExceptionString;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = new byte[roomLogo.Length];
|
|
|
|
|
using var inputStream = roomLogo.OpenReadStream();
|
|
|
|
|
|
|
|
|
|
var br = new BinaryReader(inputStream);
|
|
|
|
|
|
|
|
|
|
br.Read(data, 0, (int)roomLogo.Length);
|
|
|
|
|
br.Close();
|
|
|
|
|
|
|
|
|
|
UserPhotoThumbnailManager.CheckImgFormat(data);
|
|
|
|
|
|
|
|
|
|
result.Data = await _roomLogoManager.SaveTempAsync(data, _setupInfo.MaxImageUploadSize);
|
|
|
|
|
result.Success = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result.Success = false;
|
|
|
|
|
result.Message = ex.Message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-20 08:26:31 +00:00
|
|
|
|
private void ErrorIfNotDocSpace()
|
|
|
|
|
{
|
2022-04-28 09:40:17 +00:00
|
|
|
|
if (_coreBaseSettings.DisableDocSpace)
|
2022-04-20 08:26:31 +00:00
|
|
|
|
{
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-10 12:30:46 +00:00
|
|
|
|
}
|