Files: added deleting tags, fix
This commit is contained in:
parent
7b6abe81a2
commit
c9357da3b0
@ -0,0 +1,32 @@
|
||||
// (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.Core.ApiModels.RequestDto;
|
||||
|
||||
public class DeleteTagsRequestDto
|
||||
{
|
||||
public IEnumerable<int> TagIds { get; set; }
|
||||
}
|
@ -47,7 +47,7 @@ public class CustomTagsService<T>
|
||||
|
||||
public async Task<TagInfo> CreateTagAsync(string name)
|
||||
{
|
||||
if (_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
if (!_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
throw new SecurityException("You do not have permission to create tags");
|
||||
}
|
||||
@ -71,9 +71,9 @@ public class CustomTagsService<T>
|
||||
return await TagDao.SaveTagInfoAsync(tagInfo);
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<TagInfo> DeleteTagsAsync(IEnumerable<int> tagIds)
|
||||
public async Task DeleteTagsAsync(IEnumerable<int> tagIds)
|
||||
{
|
||||
if (_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
if (!_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
throw new SecurityException("You do not have permission to remove tags");
|
||||
}
|
||||
@ -81,11 +81,6 @@ public class CustomTagsService<T>
|
||||
var tagDao = TagDao;
|
||||
|
||||
await tagDao.RemoveTagsAsync(tagIds);
|
||||
|
||||
await foreach (var tag in GetTagsInfoAsync(string.Empty, TagType.Custom))
|
||||
{
|
||||
yield return tag;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Folder<T>> AddRoomTagsAsync(T folderId, IEnumerable<int> tagsIds)
|
||||
@ -94,7 +89,7 @@ public class CustomTagsService<T>
|
||||
|
||||
if (!await _fileSecurity.CanEditRoomAsync(folder))
|
||||
{
|
||||
throw new SecurityException("You do not have rights to edit the room");
|
||||
throw new SecurityException("You do not have permission to edit the room");
|
||||
}
|
||||
|
||||
var tagDao = TagDao;
|
||||
@ -110,16 +105,11 @@ public class CustomTagsService<T>
|
||||
|
||||
public async Task<Folder<T>> DeleteRoomTagsAsync(T folderId, IEnumerable<int> tagsIds)
|
||||
{
|
||||
if (_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
throw new SecurityException("You do not have permission to create tags");
|
||||
}
|
||||
|
||||
var folder = await FolderDao.GetFolderAsync(folderId);
|
||||
|
||||
if (!await _fileSecurity.CanEditRoomAsync(folder))
|
||||
{
|
||||
throw new SecurityException("You do not have rights to edit the room");
|
||||
throw new SecurityException("You do not have permission to edit the room");
|
||||
}
|
||||
|
||||
var tagDao = TagDao;
|
||||
|
@ -219,7 +219,7 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
}
|
||||
|
||||
[Create("rooms/{id}/tags")]
|
||||
public async Task<FolderDto<T>> AddTags(T id, [FromBody] UpdateTagsRequestDto inDto)
|
||||
public async Task<FolderDto<T>> AddTagsAsync(T id, [FromBody] UpdateTagsRequestDto inDto)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
@ -229,7 +229,7 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
}
|
||||
|
||||
[Delete("rooms/{id}/tags")]
|
||||
public async Task<FolderDto<T>> DeleteTags(T id, [FromBody] UpdateTagsRequestDto inDto)
|
||||
public async Task<FolderDto<T>> DeleteTagsAsync(T id, [FromBody] UpdateTagsRequestDto inDto)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
@ -238,15 +238,15 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
return await _folderDtoHelper.GetAsync(room);
|
||||
}
|
||||
|
||||
[Create("rooms/tags")]
|
||||
public async Task<TagInfo> CreateTag(CreateTagRequestDto inDto)
|
||||
[Create("tags")]
|
||||
public async Task<TagInfo> CreateTagAsync([FromBody] CreateTagRequestDto inDto)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
return await _customTagsService.CreateTagAsync(inDto.Name);
|
||||
}
|
||||
|
||||
[Read("rooms/tags")]
|
||||
[Read("tags")]
|
||||
public async IAsyncEnumerable<TagInfo> GetTagsInfoAsync()
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
@ -259,6 +259,14 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
[Delete("tags")]
|
||||
public async Task DeleteTagsAsync([FromBody] DeleteTagsRequestDto inDto)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
await _customTagsService.DeleteTagsAsync(inDto.TagIds);
|
||||
}
|
||||
|
||||
private void ErrorIfNotDocSpace()
|
||||
{
|
||||
if (_coreBaseSettings.DisableDocSpace)
|
||||
|
Loading…
Reference in New Issue
Block a user