Files: added api for resend room invintation
This commit is contained in:
parent
24c729078e
commit
47600daa03
@ -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 UserInvintationRequestDto
|
||||||
|
{
|
||||||
|
public IEnumerable<Guid> UsersIds { get; set; }
|
||||||
|
}
|
@ -81,6 +81,8 @@ public class FileStorageService<T> //: IFileStorageService
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly FileShareParamsHelper _fileShareParamsHelper;
|
private readonly FileShareParamsHelper _fileShareParamsHelper;
|
||||||
private readonly EncryptionLoginProvider _encryptionLoginProvider;
|
private readonly EncryptionLoginProvider _encryptionLoginProvider;
|
||||||
|
private readonly DocSpaceLinksHelper _docSpaceLinksHelper;
|
||||||
|
private readonly StudioNotifyService _studioNotifyService;
|
||||||
|
|
||||||
public FileStorageService(
|
public FileStorageService(
|
||||||
Global global,
|
Global global,
|
||||||
@ -132,7 +134,9 @@ public class FileStorageService<T> //: IFileStorageService
|
|||||||
ThirdPartySelector thirdPartySelector,
|
ThirdPartySelector thirdPartySelector,
|
||||||
ThumbnailSettings thumbnailSettings,
|
ThumbnailSettings thumbnailSettings,
|
||||||
FileShareParamsHelper fileShareParamsHelper,
|
FileShareParamsHelper fileShareParamsHelper,
|
||||||
EncryptionLoginProvider encryptionLoginProvider)
|
EncryptionLoginProvider encryptionLoginProvider,
|
||||||
|
DocSpaceLinksHelper docSpaceLinksHelper,
|
||||||
|
StudioNotifyService studioNotifyService)
|
||||||
{
|
{
|
||||||
_global = global;
|
_global = global;
|
||||||
_globalStore = globalStore;
|
_globalStore = globalStore;
|
||||||
@ -184,6 +188,8 @@ public class FileStorageService<T> //: IFileStorageService
|
|||||||
_thumbnailSettings = thumbnailSettings;
|
_thumbnailSettings = thumbnailSettings;
|
||||||
_fileShareParamsHelper = fileShareParamsHelper;
|
_fileShareParamsHelper = fileShareParamsHelper;
|
||||||
_encryptionLoginProvider = encryptionLoginProvider;
|
_encryptionLoginProvider = encryptionLoginProvider;
|
||||||
|
_docSpaceLinksHelper = docSpaceLinksHelper;
|
||||||
|
_studioNotifyService = studioNotifyService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Folder<T>> GetFolderAsync(T folderId)
|
public async Task<Folder<T>> GetFolderAsync(T folderId)
|
||||||
@ -3058,6 +3064,37 @@ public class FileStorageService<T> //: IFileStorageService
|
|||||||
return fileIds;
|
return fileIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task ResendEmailInvitationsAsync(T id, IEnumerable<Guid> usersIds)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(usersIds);
|
||||||
|
|
||||||
|
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||||
|
var room = await folderDao.GetFolderAsync(id);
|
||||||
|
|
||||||
|
ErrorIf(room == null, FilesCommonResource.ErrorMassage_FolderNotFound);
|
||||||
|
ErrorIf(!await _fileSecurity.CanEditRoomAsync(room), FilesCommonResource.ErrorMassage_SecurityException);
|
||||||
|
|
||||||
|
var shares = (await _fileSharing.GetSharedInfoAsync(room)).ToDictionary(k => k.SubjectId, v => v);
|
||||||
|
|
||||||
|
foreach (var userId in usersIds)
|
||||||
|
{
|
||||||
|
if (!shares.TryGetValue(userId, out var share))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = _userManager.GetUser(share.SubjectId, null);
|
||||||
|
|
||||||
|
if (user.ActivationStatus != EmployeeActivationStatus.Pending)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var link = _docSpaceLinksHelper.GenerateInvitationRoomLink(user.Email, EmployeeType.User, _authContext.CurrentAccount.ID, user.Id);
|
||||||
|
_studioNotifyService.SendEmailRoomInvite(user.Email, link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetHelpCenter()
|
public string GetHelpCenter()
|
||||||
{
|
{
|
||||||
return string.Empty; //TODO: Studio.UserControls.Common.HelpCenter.HelpCenter.RenderControlToString();
|
return string.Empty; //TODO: Studio.UserControls.Common.HelpCenter.HelpCenter.RenderControlToString();
|
||||||
|
@ -32,36 +32,26 @@ namespace ASC.Files.Api;
|
|||||||
public class VirtualRoomsInternalController : VirtualRoomsController<int>
|
public class VirtualRoomsInternalController : VirtualRoomsController<int>
|
||||||
{
|
{
|
||||||
public VirtualRoomsInternalController(
|
public VirtualRoomsInternalController(
|
||||||
FoldersControllerHelper<int> foldersControllerHelper,
|
|
||||||
GlobalFolderHelper globalFolderHelper,
|
GlobalFolderHelper globalFolderHelper,
|
||||||
FileOperationDtoHelper fileOperationDtoHelper,
|
FileOperationDtoHelper fileOperationDtoHelper,
|
||||||
SecurityControllerHelper<int> securityControllerHelper,
|
SecurityControllerHelper<int> securityControllerHelper,
|
||||||
CoreBaseSettings coreBaseSettings,
|
CoreBaseSettings coreBaseSettings,
|
||||||
AuthContext authContext,
|
AuthContext authContext,
|
||||||
DocSpaceLinksHelper docSpaceLinksService,
|
|
||||||
CustomTagsService<int> customTagsService,
|
CustomTagsService<int> customTagsService,
|
||||||
RoomLogoManager roomLogoManager,
|
RoomLogoManager roomLogoManager,
|
||||||
StudioNotifyService studioNotifyService,
|
|
||||||
FileStorageService<int> fileStorageService,
|
FileStorageService<int> fileStorageService,
|
||||||
FileSecurity fileSecurity,
|
|
||||||
FileSecurityCommon fileSecurityCommon,
|
|
||||||
EmailValidationKeyProvider emailValidationKeyProvider,
|
EmailValidationKeyProvider emailValidationKeyProvider,
|
||||||
FolderDtoHelper folderDtoHelper,
|
FolderDtoHelper folderDtoHelper,
|
||||||
FileDtoHelper fileDtoHelper,
|
FileDtoHelper fileDtoHelper,
|
||||||
FileShareDtoHelper fileShareDtoHelper) : base(
|
FileShareDtoHelper fileShareDtoHelper) : base(
|
||||||
foldersControllerHelper,
|
|
||||||
globalFolderHelper,
|
globalFolderHelper,
|
||||||
fileOperationDtoHelper,
|
fileOperationDtoHelper,
|
||||||
securityControllerHelper,
|
securityControllerHelper,
|
||||||
coreBaseSettings,
|
coreBaseSettings,
|
||||||
authContext,
|
authContext,
|
||||||
docSpaceLinksService,
|
|
||||||
customTagsService,
|
customTagsService,
|
||||||
roomLogoManager,
|
roomLogoManager,
|
||||||
studioNotifyService,
|
|
||||||
fileStorageService,
|
fileStorageService,
|
||||||
fileSecurity,
|
|
||||||
fileSecurityCommon,
|
|
||||||
emailValidationKeyProvider,
|
emailValidationKeyProvider,
|
||||||
folderDtoHelper,
|
folderDtoHelper,
|
||||||
fileDtoHelper,
|
fileDtoHelper,
|
||||||
@ -69,7 +59,6 @@ public class VirtualRoomsInternalController : VirtualRoomsController<int>
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a room in the virtual rooms section
|
/// Create a room in the virtual rooms section
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -99,36 +88,26 @@ public class VirtualRoomsInternalController : VirtualRoomsController<int>
|
|||||||
public class VirtualRoomsThirdPartyController : VirtualRoomsController<string>
|
public class VirtualRoomsThirdPartyController : VirtualRoomsController<string>
|
||||||
{
|
{
|
||||||
public VirtualRoomsThirdPartyController(
|
public VirtualRoomsThirdPartyController(
|
||||||
FoldersControllerHelper<string> foldersControllerHelper,
|
|
||||||
GlobalFolderHelper globalFolderHelper,
|
GlobalFolderHelper globalFolderHelper,
|
||||||
FileOperationDtoHelper fileOperationDtoHelper,
|
FileOperationDtoHelper fileOperationDtoHelper,
|
||||||
SecurityControllerHelper<string> securityControllerHelper,
|
SecurityControllerHelper<string> securityControllerHelper,
|
||||||
CoreBaseSettings coreBaseSettings,
|
CoreBaseSettings coreBaseSettings,
|
||||||
AuthContext authContext,
|
AuthContext authContext,
|
||||||
DocSpaceLinksHelper docSpaceLinksHelper,
|
|
||||||
CustomTagsService<string> customTagsService,
|
CustomTagsService<string> customTagsService,
|
||||||
RoomLogoManager roomLogoManager,
|
RoomLogoManager roomLogoManager,
|
||||||
StudioNotifyService studioNotifyService,
|
|
||||||
FileStorageService<string> fileStorageService,
|
FileStorageService<string> fileStorageService,
|
||||||
FileSecurity fileSecurity,
|
|
||||||
FileSecurityCommon fileSecurityCommon,
|
|
||||||
EmailValidationKeyProvider emailValidationKeyProvider,
|
EmailValidationKeyProvider emailValidationKeyProvider,
|
||||||
FolderDtoHelper folderDtoHelper,
|
FolderDtoHelper folderDtoHelper,
|
||||||
FileDtoHelper fileDtoHelper,
|
FileDtoHelper fileDtoHelper,
|
||||||
FileShareDtoHelper fileShareDtoHelper) : base(
|
FileShareDtoHelper fileShareDtoHelper) : base(
|
||||||
foldersControllerHelper,
|
|
||||||
globalFolderHelper,
|
globalFolderHelper,
|
||||||
fileOperationDtoHelper,
|
fileOperationDtoHelper,
|
||||||
securityControllerHelper,
|
securityControllerHelper,
|
||||||
coreBaseSettings,
|
coreBaseSettings,
|
||||||
authContext,
|
authContext,
|
||||||
docSpaceLinksHelper,
|
|
||||||
customTagsService,
|
customTagsService,
|
||||||
roomLogoManager,
|
roomLogoManager,
|
||||||
studioNotifyService,
|
|
||||||
fileStorageService,
|
fileStorageService,
|
||||||
fileSecurity,
|
|
||||||
fileSecurityCommon,
|
|
||||||
emailValidationKeyProvider,
|
emailValidationKeyProvider,
|
||||||
folderDtoHelper,
|
folderDtoHelper,
|
||||||
fileDtoHelper,
|
fileDtoHelper,
|
||||||
@ -167,54 +146,39 @@ public class VirtualRoomsThirdPartyController : VirtualRoomsController<string>
|
|||||||
|
|
||||||
public abstract class VirtualRoomsController<T> : ApiControllerBase
|
public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||||
{
|
{
|
||||||
private readonly FoldersControllerHelper<T> _foldersControllerHelper;
|
|
||||||
private readonly GlobalFolderHelper _globalFolderHelper;
|
private readonly GlobalFolderHelper _globalFolderHelper;
|
||||||
private readonly FileOperationDtoHelper _fileOperationDtoHelper;
|
private readonly FileOperationDtoHelper _fileOperationDtoHelper;
|
||||||
private readonly SecurityControllerHelper<T> _securityControllerHelper;
|
private readonly SecurityControllerHelper<T> _securityControllerHelper;
|
||||||
private readonly CoreBaseSettings _coreBaseSettings;
|
private readonly CoreBaseSettings _coreBaseSettings;
|
||||||
private readonly AuthContext _authContext;
|
private readonly AuthContext _authContext;
|
||||||
private readonly DocSpaceLinksHelper _docSpaceLinksHelper;
|
|
||||||
private readonly CustomTagsService<T> _customTagsService;
|
private readonly CustomTagsService<T> _customTagsService;
|
||||||
private readonly RoomLogoManager _roomLogoManager;
|
private readonly RoomLogoManager _roomLogoManager;
|
||||||
private readonly StudioNotifyService _studioNotifyService;
|
|
||||||
protected readonly FileStorageService<T> _fileStorageService;
|
protected readonly FileStorageService<T> _fileStorageService;
|
||||||
private readonly FileSecurity _fileSecurity;
|
|
||||||
private readonly FileSecurityCommon _fileSecurityCommon;
|
|
||||||
private readonly EmailValidationKeyProvider _emailValidationKeyProvider;
|
private readonly EmailValidationKeyProvider _emailValidationKeyProvider;
|
||||||
private readonly FileShareDtoHelper _fileShareDtoHelper;
|
private readonly FileShareDtoHelper _fileShareDtoHelper;
|
||||||
|
|
||||||
protected VirtualRoomsController(
|
protected VirtualRoomsController(
|
||||||
FoldersControllerHelper<T> foldersControllerHelper,
|
|
||||||
GlobalFolderHelper globalFolderHelper,
|
GlobalFolderHelper globalFolderHelper,
|
||||||
FileOperationDtoHelper fileOperationDtoHelper,
|
FileOperationDtoHelper fileOperationDtoHelper,
|
||||||
SecurityControllerHelper<T> securityControllerHelper,
|
SecurityControllerHelper<T> securityControllerHelper,
|
||||||
CoreBaseSettings coreBaseSettings,
|
CoreBaseSettings coreBaseSettings,
|
||||||
AuthContext authContext,
|
AuthContext authContext,
|
||||||
DocSpaceLinksHelper docSpaceLinksHelper,
|
|
||||||
CustomTagsService<T> customTagsService,
|
CustomTagsService<T> customTagsService,
|
||||||
RoomLogoManager roomLogoManager,
|
RoomLogoManager roomLogoManager,
|
||||||
StudioNotifyService studioNotifyService,
|
|
||||||
FileStorageService<T> fileStorageService,
|
FileStorageService<T> fileStorageService,
|
||||||
FileSecurity fileSecurity,
|
|
||||||
FileSecurityCommon fileSecurityCommon,
|
|
||||||
EmailValidationKeyProvider emailValidationKeyProvider,
|
EmailValidationKeyProvider emailValidationKeyProvider,
|
||||||
FolderDtoHelper folderDtoHelper,
|
FolderDtoHelper folderDtoHelper,
|
||||||
FileDtoHelper fileDtoHelper,
|
FileDtoHelper fileDtoHelper,
|
||||||
FileShareDtoHelper fileShareDtoHelper) : base(folderDtoHelper, fileDtoHelper)
|
FileShareDtoHelper fileShareDtoHelper) : base(folderDtoHelper, fileDtoHelper)
|
||||||
{
|
{
|
||||||
_foldersControllerHelper = foldersControllerHelper;
|
|
||||||
_globalFolderHelper = globalFolderHelper;
|
_globalFolderHelper = globalFolderHelper;
|
||||||
_fileOperationDtoHelper = fileOperationDtoHelper;
|
_fileOperationDtoHelper = fileOperationDtoHelper;
|
||||||
_securityControllerHelper = securityControllerHelper;
|
_securityControllerHelper = securityControllerHelper;
|
||||||
_coreBaseSettings = coreBaseSettings;
|
_coreBaseSettings = coreBaseSettings;
|
||||||
_authContext = authContext;
|
_authContext = authContext;
|
||||||
_docSpaceLinksHelper = docSpaceLinksHelper;
|
|
||||||
_customTagsService = customTagsService;
|
_customTagsService = customTagsService;
|
||||||
_roomLogoManager = roomLogoManager;
|
_roomLogoManager = roomLogoManager;
|
||||||
_studioNotifyService = studioNotifyService;
|
|
||||||
_fileStorageService = fileStorageService;
|
_fileStorageService = fileStorageService;
|
||||||
_fileSecurity = fileSecurity;
|
|
||||||
_fileSecurityCommon = fileSecurityCommon;
|
|
||||||
_emailValidationKeyProvider = emailValidationKeyProvider;
|
_emailValidationKeyProvider = emailValidationKeyProvider;
|
||||||
_fileShareDtoHelper = fileShareDtoHelper;
|
_fileShareDtoHelper = fileShareDtoHelper;
|
||||||
}
|
}
|
||||||
@ -560,6 +524,12 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
|||||||
return await _folderDtoHelper.GetAsync(room);
|
return await _folderDtoHelper.GetAsync(room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("rooms/{id}/resend")]
|
||||||
|
public async Task ResendEmailInvitationsAsync(T id, UserInvintationRequestDto inDto)
|
||||||
|
{
|
||||||
|
await _fileStorageService.ResendEmailInvitationsAsync(id, inDto.UsersIds);
|
||||||
|
}
|
||||||
|
|
||||||
protected void ErrorIfNotDocSpace()
|
protected void ErrorIfNotDocSpace()
|
||||||
{
|
{
|
||||||
if (_coreBaseSettings.DisableDocSpace)
|
if (_coreBaseSettings.DisableDocSpace)
|
||||||
@ -589,17 +559,6 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
|||||||
yield return s;
|
yield return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ErrorIfNotRights(T id, FileShare share)
|
|
||||||
{
|
|
||||||
var room = await _fileStorageService.GetFolderAsync(id);
|
|
||||||
|
|
||||||
if ((share == FileShare.RoomManager && !_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
|
||||||
|| !await _fileSecurity.CanEditRoomAsync(room))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("You don't have the rights to invite users to the room");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VirtualRoomsCommonController : ApiControllerBase
|
public class VirtualRoomsCommonController : ApiControllerBase
|
||||||
|
Loading…
Reference in New Issue
Block a user