Merge branch 'develop' into feature/push
This commit is contained in:
commit
e7fa60d13c
@ -67,7 +67,7 @@ public class FileShareDtoHelper
|
||||
_employeeWraperFullHelper = employeeWraperFullHelper;
|
||||
}
|
||||
|
||||
public FileShareDto Get(AceWrapper aceWrapper)
|
||||
public async Task<FileShareDto> Get(AceWrapper aceWrapper)
|
||||
{
|
||||
var result = new FileShareDto
|
||||
{
|
||||
@ -93,7 +93,7 @@ public class FileShareDtoHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
result.SharedTo = _employeeWraperFullHelper.GetFull(_userManager.GetUsers(aceWrapper.SubjectId));
|
||||
result.SharedTo = await _employeeWraperFullHelper.GetFull(_userManager.GetUsers(aceWrapper.SubjectId));
|
||||
}
|
||||
|
||||
result.Access = aceWrapper.Share;
|
||||
|
@ -109,7 +109,7 @@ public class FolderDtoHelper : FileEntryDtoHelper
|
||||
result.Tags = folder.Tags.Select(t => t.Name);
|
||||
}
|
||||
|
||||
result.Logo = await _roomLogoManager.GetLogo(folder.Id);
|
||||
result.Logo = await _roomLogoManager.GetLogo(folder);
|
||||
result.RoomType = folder.FolderType switch
|
||||
{
|
||||
FolderType.FillingFormsRoom => RoomType.FillingFormsRoom,
|
||||
|
@ -36,7 +36,7 @@ public interface IProviderInfo : IDisposable
|
||||
DateTime CreateOn { get; }
|
||||
string CustomerTitle { get; }
|
||||
string RootFolderId { get; }
|
||||
string FolderId { get; }
|
||||
string FolderId { get; set; }
|
||||
|
||||
Task<bool> CheckAccessAsync();
|
||||
Task InvalidateStorageAsync();
|
||||
|
@ -157,6 +157,7 @@ public class AbstractDao
|
||||
{
|
||||
using var filesDbContext = _dbContextFactory.CreateDbContext();
|
||||
result = await Query(filesDbContext.ThirdpartyIdMapping)
|
||||
.AsNoTracking()
|
||||
.Where(r => r.HashId == id.ToString())
|
||||
.Select(r => r.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
@ -173,6 +174,7 @@ public class AbstractDao
|
||||
|
||||
using var filesDbContext = _dbContextFactory.CreateDbContext();
|
||||
await filesDbContext.AddOrUpdateAsync(r => r.ThirdpartyIdMapping, newItem);
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -739,6 +739,10 @@ public class FileSecurity : IFileSecurity
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (e.Access != FileShare.Restrict && e.CreateBy == userId && (e.FileEntryType == FileEntryType.File || folder.FolderType != FolderType.COMMON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (action == FilesSecurityActions.Delete && (e.Access == FileShare.RoomManager || e.Access == FileShare.ReadWrite))
|
||||
{
|
||||
if (file != null && (file.RootFolderType == FolderType.VirtualRooms || file.RootFolderType == FolderType.Archive))
|
||||
@ -751,10 +755,6 @@ public class FileSecurity : IFileSecurity
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (e.Access != FileShare.Restrict && e.CreateBy == userId && (e.FileEntryType == FileEntryType.File || folder.FolderType != FolderType.COMMON))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.CreateBy == userId)
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ internal class ProviderAccountDao : IProviderDao
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateProviderInfoAsync(int linkId, string folderId, FolderType folderType)
|
||||
public async Task<bool> UpdateProviderInfoAsync(int linkId, string folderId, FolderType roomType)
|
||||
{
|
||||
using var filesDbContext = _dbContextFactory.CreateDbContext();
|
||||
var forUpdate = await filesDbContext.ThirdpartyAccount
|
||||
@ -242,8 +242,9 @@ internal class ProviderAccountDao : IProviderDao
|
||||
return false;
|
||||
}
|
||||
|
||||
forUpdate.RoomType = folderType;
|
||||
forUpdate.RoomType = roomType;
|
||||
forUpdate.FolderId = folderId;
|
||||
forUpdate.FolderType = FolderType.VirtualRooms;
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
|
||||
|
@ -153,6 +153,13 @@ internal abstract class RegexDaoSelectorBase<T> : IDaoSelector<T> where T : clas
|
||||
provider.UpdateTitle(newTitle); //This will update cached version too
|
||||
}
|
||||
|
||||
public async Task UpdateProviderFolderId(T provider, string id)
|
||||
{
|
||||
var dbDao = _serviceProvider.GetService<ProviderAccountDao>();
|
||||
await dbDao.UpdateProviderInfoAsync(provider.ID, id, provider.FolderType);
|
||||
provider.FolderId = id;
|
||||
}
|
||||
|
||||
protected virtual T GetProviderInfo(int linkId)
|
||||
{
|
||||
var dbDao = _daoFactory.ProviderDao;
|
||||
|
@ -137,49 +137,63 @@ internal class SharePointDaoBase : ThirdPartyProviderDao<SharePointProviderInfo>
|
||||
.Select(r => r.Id)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var oldID in oldIDs)
|
||||
{
|
||||
var oldHashID = await MappingIDAsync(oldID);
|
||||
var newID = oldID.Replace(oldValue, newValue);
|
||||
var newHashID = await MappingIDAsync(newID);
|
||||
|
||||
var mappingForUpdate = await Query(filesDbContext.ThirdpartyIdMapping)
|
||||
.Where(r => r.HashId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var m in mappingForUpdate)
|
||||
foreach (var oldID in oldIDs)
|
||||
{
|
||||
m.Id = newID;
|
||||
m.HashId = newHashID;
|
||||
}
|
||||
var oldHashID = await MappingIDAsync(oldID);
|
||||
var newID = oldID.Replace(oldValue, newValue);
|
||||
var newHashID = await MappingIDAsync(newID);
|
||||
|
||||
var mappingForDelete = await Query(filesDbContext.ThirdpartyIdMapping)
|
||||
.Where(r => r.HashId == oldHashID).ToListAsync();
|
||||
|
||||
var mappingForInsert = mappingForDelete.Select(m => new DbFilesThirdpartyIdMapping
|
||||
{
|
||||
TenantId = m.TenantId,
|
||||
Id = newID,
|
||||
HashId = newHashID
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(mappingForDelete);
|
||||
await filesDbContext.AddRangeAsync(mappingForInsert);
|
||||
|
||||
var securityForDelete = await Query(filesDbContext.Security)
|
||||
.Where(r => r.EntryId == oldHashID).ToListAsync();
|
||||
|
||||
var securityForInsert = securityForDelete.Select(s => new DbFilesSecurity
|
||||
{
|
||||
TenantId = s.TenantId,
|
||||
TimeStamp = DateTime.Now,
|
||||
EntryId = newHashID,
|
||||
Share = s.Share,
|
||||
Subject = s.Subject,
|
||||
EntryType = s.EntryType,
|
||||
Owner = s.Owner
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(securityForDelete);
|
||||
await filesDbContext.AddRangeAsync(securityForInsert);
|
||||
|
||||
var linkForDelete = await Query(filesDbContext.TagLink)
|
||||
.Where(r => r.EntryId == oldHashID).ToListAsync();
|
||||
|
||||
var linkForInsert = linkForDelete.Select(l => new DbFilesTagLink
|
||||
{
|
||||
EntryId = newHashID,
|
||||
Count = l.Count,
|
||||
CreateBy = l.CreateBy,
|
||||
CreateOn = l.CreateOn,
|
||||
EntryType = l.EntryType,
|
||||
TagId = l.TagId,
|
||||
TenantId = l.TenantId
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(linkForDelete);
|
||||
await filesDbContext.AddRangeAsync(linkForInsert);
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
|
||||
var securityForUpdate = await Query(filesDbContext.Security)
|
||||
.Where(r => r.EntryId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var s in securityForUpdate)
|
||||
{
|
||||
s.EntryId = newHashID;
|
||||
s.TimeStamp = DateTime.Now;
|
||||
}
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
|
||||
var linkForUpdate = await Query(filesDbContext.TagLink)
|
||||
.Where(r => r.EntryId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var l in linkForUpdate)
|
||||
{
|
||||
l.EntryId = newHashID;
|
||||
}
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await tx.CommitAsync();
|
||||
await tx.CommitAsync();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -157,49 +157,63 @@ internal abstract class SharpBoxDaoBase : ThirdPartyProviderDao<SharpBoxProvider
|
||||
.Select(r => r.Id)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var oldID in oldIDs)
|
||||
{
|
||||
var oldHashID = await MappingIDAsync(oldID);
|
||||
var newID = oldID.Replace(oldValue, newValue);
|
||||
var newHashID = await MappingIDAsync(newID);
|
||||
|
||||
var mappingForUpdate = await Query(filesDbContext.ThirdpartyIdMapping)
|
||||
.Where(r => r.HashId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var m in mappingForUpdate)
|
||||
foreach (var oldID in oldIDs)
|
||||
{
|
||||
m.Id = newID;
|
||||
m.HashId = newHashID;
|
||||
}
|
||||
var oldHashID = await MappingIDAsync(oldID);
|
||||
var newID = oldID.Replace(oldValue, newValue);
|
||||
var newHashID = await MappingIDAsync(newID);
|
||||
|
||||
var mappingForDelete = await Query(filesDbContext.ThirdpartyIdMapping)
|
||||
.Where(r => r.HashId == oldHashID).ToListAsync();
|
||||
|
||||
var mappingForInsert = mappingForDelete.Select(m => new DbFilesThirdpartyIdMapping
|
||||
{
|
||||
TenantId = m.TenantId,
|
||||
Id = newID,
|
||||
HashId = newHashID
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(mappingForDelete);
|
||||
await filesDbContext.AddRangeAsync(mappingForInsert);
|
||||
|
||||
var securityForDelete = await Query(filesDbContext.Security)
|
||||
.Where(r => r.EntryId == oldHashID).ToListAsync();
|
||||
|
||||
var securityForInsert = securityForDelete.Select(s => new DbFilesSecurity
|
||||
{
|
||||
TenantId = s.TenantId,
|
||||
TimeStamp = DateTime.Now,
|
||||
EntryId = newHashID,
|
||||
Share = s.Share,
|
||||
Subject = s.Subject,
|
||||
EntryType = s.EntryType,
|
||||
Owner = s.Owner
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(securityForDelete);
|
||||
await filesDbContext.AddRangeAsync(securityForInsert);
|
||||
|
||||
var linkForDelete = await Query(filesDbContext.TagLink)
|
||||
.Where(r => r.EntryId == oldHashID).ToListAsync();
|
||||
|
||||
var linkForInsert = linkForDelete.Select(l => new DbFilesTagLink
|
||||
{
|
||||
EntryId = newHashID,
|
||||
Count = l.Count,
|
||||
CreateBy = l.CreateBy,
|
||||
CreateOn = l.CreateOn,
|
||||
EntryType = l.EntryType,
|
||||
TagId = l.TagId,
|
||||
TenantId = l.TenantId
|
||||
});
|
||||
|
||||
filesDbContext.RemoveRange(linkForDelete);
|
||||
await filesDbContext.AddRangeAsync(linkForInsert);
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
|
||||
var securityForUpdate = await Query(filesDbContext.Security)
|
||||
.Where(r => r.EntryId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var s in securityForUpdate)
|
||||
{
|
||||
s.EntryId = newHashID;
|
||||
s.TimeStamp = DateTime.Now;
|
||||
}
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
|
||||
var linkForUpdate = await Query(filesDbContext.TagLink)
|
||||
.Where(r => r.EntryId == oldHashID)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var l in linkForUpdate)
|
||||
{
|
||||
l.EntryId = newHashID;
|
||||
}
|
||||
|
||||
await filesDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await tx.CommitAsync();
|
||||
await tx.CommitAsync();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -461,6 +461,11 @@ internal class SharpBoxFolderDao : SharpBoxDaoBase, IFolderDao<string>
|
||||
//We can't search google folders by title because root can have multiple folders with the same name
|
||||
//var newFolder = SharpBoxProviderInfo.Storage.GetFileSystemObject(newTitle, folder.Parent);
|
||||
newId = MakeId(entry);
|
||||
|
||||
if (DocSpaceHelper.IsRoom(ProviderInfo.FolderType))
|
||||
{
|
||||
await DaoSelector.UpdateProviderFolderId(ProviderInfo, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,9 @@ public class RoomLogoManager
|
||||
var fileName = Path.GetFileName(tempFile);
|
||||
var data = await GetTempAsync(fileName);
|
||||
|
||||
id = GetId(room);
|
||||
|
||||
await DeleteLogo(id);
|
||||
await SaveWithProcessAsync(id, data, -1, new Point(x, y), new Size(width, height));
|
||||
|
||||
if (EnableAudit)
|
||||
@ -110,17 +113,16 @@ public class RoomLogoManager
|
||||
throw new InvalidOperationException("You don't have permission to edit the room");
|
||||
}
|
||||
|
||||
id = GetId(room);
|
||||
|
||||
try
|
||||
{
|
||||
await DataStore.DeleteFilesAsync(string.Empty, $"{ProcessFolderId(id)}*.*", false);
|
||||
await DeleteLogo(id);
|
||||
|
||||
if (EnableAudit)
|
||||
{
|
||||
_filesMessageService.Send(room, Headers, MessageAction.RoomLogoDeleted);
|
||||
}
|
||||
|
||||
_cache.Remove(_cachePattern);
|
||||
_cache.Remove(GetKey(id));
|
||||
}
|
||||
catch (DirectoryNotFoundException e)
|
||||
{
|
||||
@ -130,8 +132,10 @@ public class RoomLogoManager
|
||||
return room;
|
||||
}
|
||||
|
||||
public async Task<Logo> GetLogo<T>(T id)
|
||||
public async Task<Logo> GetLogo<T>(Folder<T> room)
|
||||
{
|
||||
var id = GetId(room);
|
||||
|
||||
return new Logo
|
||||
{
|
||||
Original = await GetOriginalLogoPath(id),
|
||||
@ -169,7 +173,7 @@ public class RoomLogoManager
|
||||
using var stream = new MemoryStream(data);
|
||||
var path = await DataStore.SaveAsync(TempDomainPath, fileName, stream);
|
||||
|
||||
return path.ToString();
|
||||
return path.RemoveQueryParams("auth", "expire").ToString();
|
||||
}
|
||||
|
||||
public async Task<string> SaveWithProcessAsync<T>(T id, byte[] imageData, long maxFileSize, Point position, Size cropSize)
|
||||
@ -294,6 +298,14 @@ public class RoomLogoManager
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteLogo<T>(T id)
|
||||
{
|
||||
await DataStore.DeleteFilesAsync(string.Empty, $"{ProcessFolderId(id)}*.*", false);
|
||||
|
||||
_cache.Remove(_cachePattern);
|
||||
_cache.Remove(GetKey(id));
|
||||
}
|
||||
|
||||
private string ProcessFolderId<T>(T id)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(id, nameof(id));
|
||||
@ -312,4 +324,10 @@ public class RoomLogoManager
|
||||
{
|
||||
return $"{TenantId}/{id}/orig";
|
||||
}
|
||||
|
||||
private T GetId<T>(Folder<T> room)
|
||||
{
|
||||
return room.ProviderEntry && (room.RootId.ToString().Contains("sbox")
|
||||
|| room.RootId.ToString().Contains("spoint")) ? room.RootId : room.Id;
|
||||
}
|
||||
}
|
@ -166,6 +166,8 @@ global using DocuSign.eSign.Model;
|
||||
global using Dropbox.Api;
|
||||
global using Dropbox.Api.Files;
|
||||
|
||||
global using Flurl;
|
||||
|
||||
global using Google;
|
||||
global using Google.Apis.Auth.OAuth2;
|
||||
global using Google.Apis.Auth.OAuth2.Flows;
|
||||
|
@ -88,9 +88,12 @@ public abstract class SecutiryController<T> : ApiControllerBase
|
||||
/// <param name="fileId">File ID</param>
|
||||
/// <returns>Shared file information</returns>
|
||||
[HttpGet("file/{fileId}/share")]
|
||||
public Task<IEnumerable<FileShareDto>> GetFileSecurityInfoAsync(T fileId)
|
||||
public async IAsyncEnumerable<FileShareDto> GetFileSecurityInfoAsync(T fileId)
|
||||
{
|
||||
return _securityControllerHelper.GetFileSecurityInfoAsync(fileId);
|
||||
await foreach (var s in _securityControllerHelper.GetFileSecurityInfoAsync(fileId))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,9 +104,12 @@ public abstract class SecutiryController<T> : ApiControllerBase
|
||||
/// <category>Sharing</category>
|
||||
/// <returns>Shared folder information</returns>
|
||||
[HttpGet("folder/{folderId}/share")]
|
||||
public Task<IEnumerable<FileShareDto>> GetFolderSecurityInfoAsync(T folderId)
|
||||
public async IAsyncEnumerable<FileShareDto> GetFolderSecurityInfoAsync(T folderId)
|
||||
{
|
||||
return _securityControllerHelper.GetFolderSecurityInfoAsync(folderId);
|
||||
await foreach (var s in _securityControllerHelper.GetFolderSecurityInfoAsync(folderId))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{fileId}/setacelink")]
|
||||
@ -126,9 +132,12 @@ public abstract class SecutiryController<T> : ApiControllerBase
|
||||
/// </remarks>
|
||||
/// <returns>Shared file information</returns>
|
||||
[HttpPut("file/{fileId}/share")]
|
||||
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoAsync(T fileId, SecurityInfoRequestDto inDto)
|
||||
public async IAsyncEnumerable<FileShareDto> SetFileSecurityInfoAsync(T fileId, SecurityInfoRequestDto inDto)
|
||||
{
|
||||
return _securityControllerHelper.SetFileSecurityInfoAsync(fileId, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
await foreach (var s in _securityControllerHelper.SetSecurityInfoAsync(new List<T> { fileId }, new List<T>(), inDto.Share, inDto.Notify, inDto.SharingMessage))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -145,9 +154,12 @@ public abstract class SecutiryController<T> : ApiControllerBase
|
||||
/// <category>Sharing</category>
|
||||
/// <returns>Shared folder information</returns>
|
||||
[HttpPut("folder/{folderId}/share")]
|
||||
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoAsync(T folderId, SecurityInfoRequestDto inDto)
|
||||
public async IAsyncEnumerable<FileShareDto> SetFolderSecurityInfoAsync(T folderId, SecurityInfoRequestDto inDto)
|
||||
{
|
||||
return _securityControllerHelper.SetFolderSecurityInfoAsync(folderId, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
await foreach (var s in _securityControllerHelper.SetSecurityInfoAsync(new List<T>(), new List<T> { folderId }, inDto.Share, inDto.Notify, inDto.SharingMessage))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("file/{fileId}/publickeys")]
|
||||
@ -201,16 +213,18 @@ public class SecutiryControllerCommon : ApiControllerBase
|
||||
}
|
||||
|
||||
[HttpPost("share")]
|
||||
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoAsync(BaseBatchRequestDto inDto)
|
||||
public async IAsyncEnumerable<FileShareDto> GetSecurityInfoAsync(BaseBatchRequestDto inDto)
|
||||
{
|
||||
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
|
||||
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
|
||||
|
||||
var result = new List<FileShareDto>();
|
||||
result.AddRange(await _securityControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds));
|
||||
result.AddRange(await _securityControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds));
|
||||
|
||||
return result;
|
||||
|
||||
var internalIds = _securityControllerHelperInt.GetSecurityInfoAsync(fileIntIds, folderIntIds);
|
||||
var thirdpartyIds = _securityControllerHelperString.GetSecurityInfoAsync(fileStringIds, folderStringIds);
|
||||
|
||||
await foreach (var r in internalIds.Concat(thirdpartyIds))
|
||||
{
|
||||
yield return r;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -235,15 +249,17 @@ public class SecutiryControllerCommon : ApiControllerBase
|
||||
|
||||
|
||||
[HttpPut("share")]
|
||||
public async Task<IEnumerable<FileShareDto>> SetSecurityInfoAsync(SecurityInfoRequestDto inDto)
|
||||
public async IAsyncEnumerable<FileShareDto> SetSecurityInfoAsync(SecurityInfoRequestDto inDto)
|
||||
{
|
||||
var (folderIntIds, folderStringIds) = FileOperationsManager.GetIds(inDto.FolderIds);
|
||||
var (fileIntIds, fileStringIds) = FileOperationsManager.GetIds(inDto.FileIds);
|
||||
|
||||
var result = new List<FileShareDto>();
|
||||
result.AddRange(await _securityControllerHelperInt.SetSecurityInfoAsync(fileIntIds, folderIntIds, inDto.Share, inDto.Notify, inDto.SharingMessage));
|
||||
result.AddRange(await _securityControllerHelperString.SetSecurityInfoAsync(fileStringIds, folderStringIds, inDto.Share, inDto.Notify, inDto.SharingMessage));
|
||||
var internalIds = _securityControllerHelperInt.SetSecurityInfoAsync(fileIntIds, folderIntIds, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
var thirdpartyIds = _securityControllerHelperString.SetSecurityInfoAsync(fileStringIds, folderStringIds, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
|
||||
return result;
|
||||
await foreach (var s in internalIds.Concat(thirdpartyIds))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
}
|
@ -320,16 +320,24 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
/// Room security info
|
||||
/// </returns>
|
||||
[HttpPut("rooms/{id}/share")]
|
||||
public Task<IEnumerable<FileShareDto>> SetRoomSecurityAsync(T id, SecurityInfoRequestDto inDto)
|
||||
public async IAsyncEnumerable<FileShareDto> SetRoomSecurityAsync(T id, SecurityInfoRequestDto inDto)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
|
||||
IAsyncEnumerable<FileShareDto> result;
|
||||
if (!string.IsNullOrEmpty(inDto.Key))
|
||||
{
|
||||
return SetRoomSecurityByLinkAsync(id, _authContext.CurrentAccount.ID, inDto.Access, inDto.Key);
|
||||
result = SetRoomSecurityByLinkAsync(id, _authContext.CurrentAccount.ID, inDto.Access, inDto.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = _securityControllerHelper.SetFolderSecurityInfoAsync(id, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
}
|
||||
|
||||
await foreach (var r in result)
|
||||
{
|
||||
yield return r;
|
||||
}
|
||||
|
||||
return _securityControllerHelper.SetFolderSecurityInfoAsync(id, inDto.Share, inDto.Notify, inDto.SharingMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -568,7 +576,7 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<FileShareDto>> SetRoomSecurityByLinkAsync(T id, Guid userId, FileShare access, string key)
|
||||
private async IAsyncEnumerable<FileShareDto> SetRoomSecurityByLinkAsync(T id, Guid userId, FileShare access, string key)
|
||||
{
|
||||
var result = _emailValidationKeyProvider.ValidateEmailKey(string.Empty + ConfirmType.LinkInvite + ((int)EmployeeType.User + (int)access + id.ToString()), key,
|
||||
_emailValidationKeyProvider.ValidEmailKeyInterval);
|
||||
@ -584,7 +592,10 @@ public abstract class VirtualRoomsController<T> : ApiControllerBase
|
||||
Access = access
|
||||
};
|
||||
|
||||
return await _securityControllerHelper.SetFolderSecurityInfoAsync(id, new[] { share }, false, null, true);
|
||||
await foreach (var s in _securityControllerHelper.SetFolderSecurityInfoAsync(id, new[] { share }, false, null, true))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ErrorIfNotRights(T id, FileShare share)
|
||||
|
@ -95,21 +95,24 @@ public class SecurityControllerHelper<T> : FilesHelperBase<T>
|
||||
return sharedInfo.Link;
|
||||
}
|
||||
|
||||
public Task<IEnumerable<FileShareDto>> GetFileSecurityInfoAsync(T fileId)
|
||||
public IAsyncEnumerable<FileShareDto> GetFileSecurityInfoAsync(T fileId)
|
||||
{
|
||||
return GetSecurityInfoAsync(new List<T> { fileId }, new List<T> { });
|
||||
}
|
||||
|
||||
public Task<IEnumerable<FileShareDto>> GetFolderSecurityInfoAsync(T folderId)
|
||||
public IAsyncEnumerable<FileShareDto> GetFolderSecurityInfoAsync(T folderId)
|
||||
{
|
||||
return GetSecurityInfoAsync(new List<T> { }, new List<T> { folderId });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileShareDto>> GetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds, bool invite = false)
|
||||
public async IAsyncEnumerable<FileShareDto> GetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds, bool invite = false)
|
||||
{
|
||||
var fileShares = await _fileStorageService.GetSharedInfoAsync(fileIds, folderIds, invite);
|
||||
|
||||
return fileShares.Select(_fileShareDtoHelper.Get).ToList();
|
||||
|
||||
foreach (var fileShareDto in fileShares)
|
||||
{
|
||||
yield return await _fileShareDtoHelper.Get(fileShareDto);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> RemoveSecurityInfoAsync(List<T> fileIds, List<T> folderIds)
|
||||
@ -119,17 +122,12 @@ public class SecurityControllerHelper<T> : FilesHelperBase<T>
|
||||
return true;
|
||||
}
|
||||
|
||||
public Task<IEnumerable<FileShareDto>> SetFileSecurityInfoAsync(T fileId, IEnumerable<FileShareParams> share, bool notify, string sharingMessage)
|
||||
{
|
||||
return SetSecurityInfoAsync(new List<T> { fileId }, new List<T>(), share, notify, sharingMessage);
|
||||
}
|
||||
|
||||
public Task<IEnumerable<FileShareDto>> SetFolderSecurityInfoAsync(T folderId, IEnumerable<FileShareParams> share, bool notify, string sharingMessage, bool invite = false)
|
||||
public IAsyncEnumerable<FileShareDto> SetFolderSecurityInfoAsync(T folderId, IEnumerable<FileShareParams> share, bool notify, string sharingMessage, bool invite = false)
|
||||
{
|
||||
return SetSecurityInfoAsync(new List<T>(), new List<T> { folderId }, share, notify, sharingMessage, invite);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<FileShareDto>> SetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds, IEnumerable<FileShareParams> share, bool notify, string sharingMessage, bool invite = false)
|
||||
public async IAsyncEnumerable<FileShareDto> SetSecurityInfoAsync(IEnumerable<T> fileIds, IEnumerable<T> folderIds, IEnumerable<FileShareParams> share, bool notify, string sharingMessage, bool invite = false)
|
||||
{
|
||||
if (share != null && share.Any())
|
||||
{
|
||||
@ -146,6 +144,9 @@ public class SecurityControllerHelper<T> : FilesHelperBase<T>
|
||||
await _fileStorageService.SetAceObjectAsync(aceCollection, notify, invite);
|
||||
}
|
||||
|
||||
return await GetSecurityInfoAsync(fileIds, folderIds, invite);
|
||||
await foreach (var s in GetSecurityInfoAsync(fileIds, folderIds, invite))
|
||||
{
|
||||
yield return s;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user