Files: fix filter, refactor, removed unnecessary
This commit is contained in:
parent
552d2adda8
commit
cab55d68f3
@ -57,10 +57,10 @@ public interface IFolderDao<T>
|
||||
/// <returns>root folder</returns>
|
||||
Task<Folder<T>> GetRootFolderByFileAsync(T fileId);
|
||||
|
||||
IAsyncEnumerable<Folder<T>> GetRoomsAsync(T parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
IAsyncEnumerable<Folder<T>> GetRoomsAsync(T parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
bool withoutTags, bool withoutMe);
|
||||
|
||||
IAsyncEnumerable<Folder<T>> GetRoomsAsync(IEnumerable<T> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
IAsyncEnumerable<Folder<T>> GetRoomsAsync(IEnumerable<T> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
bool withoutTags, bool withoutMe);
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,10 +48,6 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
private readonly CrossDao _crossDao;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
private static readonly List<FilterType> _constraintFolderFilters =
|
||||
new() { FilterType.FilesOnly, FilterType.ByExtension, FilterType.DocumentsOnly, FilterType.ImagesOnly,
|
||||
FilterType.PresentationsOnly, FilterType.SpreadsheetsOnly, FilterType.ArchiveOnly, FilterType.MediaOnly };
|
||||
|
||||
public FolderDao(
|
||||
FactoryIndexerFolder factoryIndexer,
|
||||
UserManager userManager,
|
||||
@ -163,18 +159,18 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
return GetFoldersAsync(parentId, default, FilterType.None, false, default, string.Empty);
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<int>> GetRoomsAsync(int parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
public IAsyncEnumerable<Folder<int>> GetRoomsAsync(int parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<int>>();
|
||||
}
|
||||
|
||||
var filter = GetRoomTypeFilter(filterTypes);
|
||||
|
||||
var filter = GetRoomTypeFilter(filterType);
|
||||
|
||||
var searchByTags = tags != null && tags.Any() && !withoutTags;
|
||||
var searchByTypes = filterTypes.Any() && !filterTypes.Contains(FilterType.None);
|
||||
var searchByTypes = filterType != FilterType.None;
|
||||
|
||||
var q = GetFolderQuery(r => r.ParentId == parentId).AsNoTracking();
|
||||
|
||||
@ -192,19 +188,19 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
return dbFolders.Select(_mapper.Map<DbFolderQuery, Folder<int>>);
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<int>> GetRoomsAsync(IEnumerable<int> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText,
|
||||
public IAsyncEnumerable<Folder<int>> GetRoomsAsync(IEnumerable<int> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText,
|
||||
bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<int>>();
|
||||
}
|
||||
|
||||
var filter = GetRoomTypeFilter(filterTypes);
|
||||
|
||||
var filter = GetRoomTypeFilter(filterType);
|
||||
|
||||
var searchByTags = tags != null && tags.Any() && !withoutTags;
|
||||
var searchByTypes = filterTypes.Any() && !filterTypes.Contains(FilterType.None);
|
||||
|
||||
var searchByTypes = filterType != FilterType.None;
|
||||
|
||||
var q = GetFolderQuery(f => roomsIds.Contains(f.Id)).AsNoTracking();
|
||||
|
||||
q = !withSubfolders ? BuildRoomsQuery(q, filter, tags, ownerId, searchByTags, withoutTags, searchByTypes, false, withoutMe)
|
||||
@ -223,12 +219,11 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
|
||||
public IAsyncEnumerable<Folder<int>> GetFoldersAsync(int parentId, OrderBy orderBy, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, bool withSubfolders = false)
|
||||
{
|
||||
if (filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly or FilterType.SpreadsheetsOnly
|
||||
or FilterType.ArchiveOnly or FilterType.MediaOnly)
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<int>>();
|
||||
}
|
||||
|
||||
|
||||
orderBy ??= new OrderBy(SortedByType.DateAndTime, false);
|
||||
|
||||
var q = GetFolderQuery(r => r.ParentId == parentId).AsNoTracking();
|
||||
@ -282,8 +277,7 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
|
||||
public IAsyncEnumerable<Folder<int>> GetFoldersAsync(IEnumerable<int> folderIds, FilterType filterType = FilterType.None, bool subjectGroup = false, Guid? subjectID = null, string searchText = "", bool searchSubfolders = false, bool checkShare = true)
|
||||
{
|
||||
if (filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly or FilterType.SpreadsheetsOnly
|
||||
or FilterType.ArchiveOnly or FilterType.MediaOnly)
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<int>>();
|
||||
}
|
||||
@ -1379,17 +1373,18 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
return q1.Union(q2);
|
||||
}
|
||||
|
||||
private IQueryable<DbFolder> BuildRoomsQuery(IQueryable<DbFolder> query, IEnumerable<FolderType> filter, IEnumerable<string> tags, Guid ownerId, bool searchByTags, bool withoutTags,
|
||||
private IQueryable<DbFolder> BuildRoomsQuery(IQueryable<DbFolder> query, FolderType filterByType, IEnumerable<string> tags, Guid ownerId, bool searchByTags, bool withoutTags,
|
||||
bool searchByFilter, bool withSubfolders, bool withoutMe)
|
||||
{
|
||||
if (searchByFilter)
|
||||
{
|
||||
query = query.Where(f => filter.Contains(f.FolderType));
|
||||
query = query.Where(f => f.FolderType == filterByType);
|
||||
}
|
||||
|
||||
if (withoutTags)
|
||||
{
|
||||
query = query.Where(f => !FilesDbContext.TagLink.Any(t => t.EntryId == f.Id.ToString()));
|
||||
query = query.Where(f => !FilesDbContext.TagLink.Join(FilesDbContext.Tag, l => l.TagId, t => t.Id, (link, tag) => new {link.EntryId, tag})
|
||||
.Where(r => r.tag.Type == TagType.Custom).Any(t => t.EntryId == f.Id.ToString()));
|
||||
}
|
||||
|
||||
if (ownerId != Guid.Empty && !withoutMe)
|
||||
@ -1413,12 +1408,12 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
return query;
|
||||
}
|
||||
|
||||
private IQueryable<DbFolder> BuildRoomsWithSubfoldersQuery(int parentId, IEnumerable<FolderType> filter, IEnumerable<string> tags, bool searchByTags, bool searchByFilter, bool withoutTags,
|
||||
private IQueryable<DbFolder> BuildRoomsWithSubfoldersQuery(int parentId, FolderType filterByType, IEnumerable<string> tags, bool searchByTags, bool searchByFilter, bool withoutTags,
|
||||
bool withoutMe, Guid ownerId)
|
||||
{
|
||||
var q1 = GetFolderQuery(r => r.ParentId == parentId).AsNoTracking();
|
||||
|
||||
q1 = BuildRoomsQuery(q1, filter, tags, ownerId, searchByTags, withoutTags, searchByFilter, true, withoutMe);
|
||||
q1 = BuildRoomsQuery(q1, filterByType, tags, ownerId, searchByTags, withoutTags, searchByFilter, true, withoutMe);
|
||||
|
||||
if (searchByTags)
|
||||
{
|
||||
@ -1445,12 +1440,12 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
.Select(r => r.folder);
|
||||
}
|
||||
|
||||
private IQueryable<DbFolder> BuildRoomsWithSubfoldersQuery(IEnumerable<int> roomsIds, IEnumerable<FolderType> filter, IEnumerable<string> tags, bool searchByTags, bool searchByFilter, bool withoutTags,
|
||||
private IQueryable<DbFolder> BuildRoomsWithSubfoldersQuery(IEnumerable<int> roomsIds, FolderType filterByType, IEnumerable<string> tags, bool searchByTags, bool searchByFilter, bool withoutTags,
|
||||
bool withoutMe, Guid ownerId)
|
||||
{
|
||||
var q1 = GetFolderQuery(f => roomsIds.Contains(f.Id)).AsNoTracking();
|
||||
|
||||
q1 = BuildRoomsQuery(q1, filter, tags, ownerId, searchByTags, withoutTags, searchByFilter, true, withoutMe);
|
||||
q1 = BuildRoomsQuery(q1, filterByType, tags, ownerId, searchByTags, withoutTags, searchByFilter, true, withoutMe);
|
||||
|
||||
if (searchByTags)
|
||||
{
|
||||
@ -1477,42 +1472,23 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
|
||||
.Select(r => r.folder);
|
||||
}
|
||||
|
||||
private bool CheckForInvalidFilters(IEnumerable<FilterType> filterTypes)
|
||||
private bool CheckInvalidFilter(FilterType filterType)
|
||||
{
|
||||
var intersection = filterTypes.Intersect(_constraintFolderFilters);
|
||||
|
||||
return !intersection.Any();
|
||||
return filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly
|
||||
or FilterType.SpreadsheetsOnly or FilterType.ArchiveOnly or FilterType.MediaOnly;
|
||||
}
|
||||
|
||||
private IEnumerable<FolderType> GetRoomTypeFilter(IEnumerable<FilterType> filterTypes)
|
||||
private FolderType GetRoomTypeFilter(FilterType filterType)
|
||||
{
|
||||
var filter = new List<FolderType>();
|
||||
|
||||
foreach (var f in filterTypes)
|
||||
return filterType switch
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case FilterType.FillingFormsRooms:
|
||||
filter.Add(FolderType.FillingFormsRoom);
|
||||
break;
|
||||
case FilterType.EditingRooms:
|
||||
filter.Add(FolderType.EditingRoom);
|
||||
break;
|
||||
case FilterType.ReviewRooms:
|
||||
filter.Add(FolderType.ReviewRoom);
|
||||
break;
|
||||
case FilterType.ReadOnlyRooms:
|
||||
filter.Add(FolderType.ReadOnlyRoom);
|
||||
break;
|
||||
case FilterType.CustomRooms:
|
||||
filter.Add(FolderType.CustomRoom);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return filter.ToHashSet();
|
||||
FilterType.FillingFormsRooms => FolderType.FillingFormsRoom,
|
||||
FilterType.EditingRooms => FolderType.EditingRoom,
|
||||
FilterType.ReviewRooms => FolderType.ReviewRoom,
|
||||
FilterType.ReadOnlyRooms => FolderType.ReadOnlyRoom,
|
||||
FilterType.CustomRooms => FolderType.CustomRoom,
|
||||
_ => FolderType.CustomRoom,
|
||||
};
|
||||
}
|
||||
|
||||
private string GetProjectTitle(object folderID)
|
||||
|
@ -237,14 +237,7 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
}));
|
||||
}
|
||||
|
||||
public async Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, FilterType filter, bool subjectGroup, string subject, string searchText, bool searchInContent,
|
||||
bool withSubfolders, OrderBy orderBy, SearchArea searchArea = SearchArea.Active, bool withoutTags = false, IEnumerable<string> tagNames = null, bool withoutMe = false)
|
||||
{
|
||||
return await GetFolderItemsAsync(parentId, from, count, new[] { filter }, subjectGroup, subject, searchText, searchInContent, withSubfolders, orderBy, searchArea, withoutTags,
|
||||
tagNames, withoutMe);
|
||||
}
|
||||
|
||||
public async Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, IEnumerable<FilterType> filterTypes, bool subjectGroup, string subject, string searchText,
|
||||
public async Task<DataWrapper<T>> GetFolderItemsAsync(T parentId, int from, int count, FilterType filterType, bool subjectGroup, string subject, string searchText,
|
||||
bool searchInContent, bool withSubfolders, OrderBy orderBy, SearchArea searchArea = SearchArea.Active, bool withoutTags = false, IEnumerable<string> tagNames = null, bool withoutMe = false)
|
||||
{
|
||||
var subjectId = string.IsNullOrEmpty(subject) ? Guid.Empty : new Guid(subject);
|
||||
@ -292,7 +285,7 @@ public class FileStorageService<T> //: IFileStorageService
|
||||
IEnumerable<FileEntry> entries;
|
||||
try
|
||||
{
|
||||
(entries, total) = await _entryManager.GetEntriesAsync(parent, from, count, filterTypes, subjectGroup, subjectId, searchText, searchInContent, withSubfolders, orderBy, searchArea,
|
||||
(entries, total) = await _entryManager.GetEntriesAsync(parent, from, count, filterType, subjectGroup, subjectId, searchText, searchInContent, withSubfolders, orderBy, searchArea,
|
||||
withoutTags, tagNames, withoutMe);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -1051,12 +1051,12 @@ public class FileSecurity : IFileSecurity
|
||||
return entries.Where(x => string.IsNullOrEmpty(x.Error)).Cast<FileEntry>().ToList();
|
||||
}
|
||||
|
||||
public async Task<List<FileEntry>> GetVirtualRoomsAsync(IEnumerable<FilterType> filterTypes, Guid subjectId, string searchText, bool searchInContent, bool withSubfolders,
|
||||
public async Task<List<FileEntry>> GetVirtualRoomsAsync(FilterType filterType, Guid subjectId, string searchText, bool searchInContent, bool withSubfolders,
|
||||
SearchArea searchArea, bool withoutTags, IEnumerable<string> tagNames, bool withoutMe)
|
||||
{
|
||||
if (_fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
return await GetVirtualRoomsForAdminAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
return await GetVirtualRoomsForAdminAsync(filterType, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
}
|
||||
|
||||
var securityDao = _daoFactory.GetSecurityDao<int>();
|
||||
@ -1064,9 +1064,9 @@ public class FileSecurity : IFileSecurity
|
||||
var records = await securityDao.GetSharesAsync(subjects);
|
||||
var entries = new List<FileEntry>();
|
||||
|
||||
var rooms = await GetVirtualRoomsForUserAsync<int>(records.Where(r => r.EntryId is int), subjects, filterTypes, subjectId, searchText, searchInContent,
|
||||
var rooms = await GetVirtualRoomsForUserAsync<int>(records.Where(r => r.EntryId is int), subjects, filterType, subjectId, searchText, searchInContent,
|
||||
withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
var thirdPartyRooms = await GetVirtualRoomsForUserAsync<string>(records.Where(r => r.EntryId is string), subjects, filterTypes, subjectId, searchText,
|
||||
var thirdPartyRooms = await GetVirtualRoomsForUserAsync<string>(records.Where(r => r.EntryId is string), subjects, filterType, subjectId, searchText,
|
||||
searchInContent, withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
|
||||
entries.AddRange(rooms);
|
||||
@ -1075,7 +1075,7 @@ public class FileSecurity : IFileSecurity
|
||||
return entries;
|
||||
}
|
||||
|
||||
private async Task<List<FileEntry>> GetVirtualRoomsForAdminAsync(IEnumerable<FilterType> filterTypes, Guid subjectId, string search, bool searchInContent, bool withSubfolders,
|
||||
private async Task<List<FileEntry>> GetVirtualRoomsForAdminAsync(FilterType filterType, Guid subjectId, string search, bool searchInContent, bool withSubfolders,
|
||||
SearchArea searchArea, bool withoutTags, IEnumerable<string> tagNames, bool withoutMe)
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<int>();
|
||||
@ -1093,8 +1093,8 @@ public class FileSecurity : IFileSecurity
|
||||
var roomsFolderId = await _globalFolder.GetFolderVirtualRoomsAsync<int>(_daoFactory);
|
||||
var thirdPartyRoomsIds = await providerDao.GetProvidersInfoAsync(FolderType.VirtualRooms).Select(p => p.FolderId).ToListAsync();
|
||||
|
||||
var rooms = await folderDao.GetRoomsAsync(roomsFolderId, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe).ToListAsync();
|
||||
var thirdPartyRooms = await folderThirdPartyDao.GetRoomsAsync(thirdPartyRoomsIds, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
var rooms = await folderDao.GetRoomsAsync(roomsFolderId, filterType, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe).ToListAsync();
|
||||
var thirdPartyRooms = await folderThirdPartyDao.GetRoomsAsync(thirdPartyRoomsIds, filterType, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
.ToListAsync();
|
||||
|
||||
foldersInt.AddRange(rooms);
|
||||
@ -1102,10 +1102,20 @@ public class FileSecurity : IFileSecurity
|
||||
|
||||
if (withSubfolders)
|
||||
{
|
||||
var files = await fileDao.GetFilesAsync(rooms.Where(r => DocSpaceHelper.IsRoom(r.FolderType)).Select(r => r.Id), FilterType.None, false,
|
||||
Guid.Empty, search, searchInContent);
|
||||
var thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRooms.Select(r => r.Id), FilterType.None, false, Guid.Empty, search,
|
||||
searchInContent);
|
||||
List<File<int>> files;
|
||||
List<File<string>> thirdPartyFiles;
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(roomsFolderId, null, FilterType.None, false, Guid.Empty, search, searchInContent, true).ToListAsync();
|
||||
thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRoomsIds, FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(rooms.Where(r => DocSpaceHelper.IsRoom(r.FolderType)).Select(r => r.Id), FilterType.None, false, Guid.Empty, search,
|
||||
searchInContent);
|
||||
thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRooms.Select(r => r.Id), FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
|
||||
entries.AddRange(files);
|
||||
entries.AddRange(thirdPartyFiles);
|
||||
@ -1116,8 +1126,8 @@ public class FileSecurity : IFileSecurity
|
||||
var archiveFolderId = await _globalFolder.GetFolderArchive<int>(_daoFactory);
|
||||
var thirdPartyRoomsIds = await providerDao.GetProvidersInfoAsync(FolderType.Archive).Select(p => p.FolderId).ToListAsync();
|
||||
|
||||
var rooms = await folderDao.GetRoomsAsync(archiveFolderId, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe).ToListAsync();
|
||||
var thirdPartyRooms = await folderThirdPartyDao.GetRoomsAsync(thirdPartyRoomsIds, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
var rooms = await folderDao.GetRoomsAsync(archiveFolderId, filterType, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe).ToListAsync();
|
||||
var thirdPartyRooms = await folderThirdPartyDao.GetRoomsAsync(thirdPartyRoomsIds, filterType, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
.ToListAsync();
|
||||
|
||||
foldersInt.AddRange(rooms);
|
||||
@ -1125,10 +1135,20 @@ public class FileSecurity : IFileSecurity
|
||||
|
||||
if (withSubfolders)
|
||||
{
|
||||
var files = await fileDao.GetFilesAsync(rooms.Where(r => DocSpaceHelper.IsRoom(r.FolderType)).Select(r => r.Id), FilterType.None, false,
|
||||
Guid.Empty, search, searchInContent);
|
||||
var thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRooms.Select(r => r.Id), FilterType.None, false, Guid.Empty, search,
|
||||
searchInContent);
|
||||
List<File<int>> files;
|
||||
List<File<string>> thirdPartyFiles;
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(archiveFolderId, null, FilterType.None, false, Guid.Empty, search, searchInContent, true).ToListAsync();
|
||||
thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRoomsIds, FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(rooms.Where(r => DocSpaceHelper.IsRoom(r.FolderType)).Select(r => r.Id), FilterType.None, false, Guid.Empty, search,
|
||||
searchInContent);
|
||||
thirdPartyFiles = await fileThirdPartyDao.GetFilesAsync(thirdPartyRooms.Select(r => r.Id), FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
|
||||
entries.AddRange(files);
|
||||
entries.AddRange(thirdPartyFiles);
|
||||
@ -1146,7 +1166,7 @@ public class FileSecurity : IFileSecurity
|
||||
return entries;
|
||||
}
|
||||
|
||||
private async Task<List<FileEntry>> GetVirtualRoomsForUserAsync<T>(IEnumerable<FileShareRecord> records, List<Guid> subjects, IEnumerable<FilterType> filterTypes, Guid subjectId, string search,
|
||||
private async Task<List<FileEntry>> GetVirtualRoomsForUserAsync<T>(IEnumerable<FileShareRecord> records, List<Guid> subjects, FilterType filterType, Guid subjectId, string search,
|
||||
bool searchInContent, bool withSubfolders, SearchArea searchArea, bool withoutTags, IEnumerable<string> tagNames, bool withoutMe)
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
@ -1189,7 +1209,7 @@ public class FileSecurity : IFileSecurity
|
||||
return false;
|
||||
};
|
||||
|
||||
var rooms = await folderDao.GetRoomsAsync(roomsIds.Keys, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
var rooms = await folderDao.GetRoomsAsync(roomsIds.Keys, filterType, tagNames, subjectId, search, withSubfolders, withoutTags, withoutMe)
|
||||
.Where(filter).ToListAsync();
|
||||
|
||||
await SetTagsAsync(rooms);
|
||||
@ -1199,7 +1219,17 @@ public class FileSecurity : IFileSecurity
|
||||
|
||||
if (withSubfolders)
|
||||
{
|
||||
var files = await fileDao.GetFilesAsync(rooms.OfType<Folder<T>>().Where(f => DocSpaceHelper.IsRoom(f.FolderType)).Select(r => r.Id), FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
List<File<T>> files;
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(roomsIds.Keys, FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
files = await fileDao.GetFilesAsync(rooms.OfType<Folder<T>>().Where(f => DocSpaceHelper.IsRoom(f.FolderType)).Select(r => r.Id), FilterType.None, false, Guid.Empty, search, searchInContent);
|
||||
}
|
||||
|
||||
entries.AddRange(files.Where(filter));
|
||||
}
|
||||
|
||||
|
@ -74,17 +74,17 @@ internal class BoxFolderDao : BoxDaoBase, IFolderDao<string>
|
||||
return GetRootFolderAsync(fileId);
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders,
|
||||
bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -97,17 +97,17 @@ internal class BoxFolderDao : BoxDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText,
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText,
|
||||
bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -131,8 +131,7 @@ internal class BoxFolderDao : BoxDaoBase, IFolderDao<string>
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetFoldersAsync(string parentId, OrderBy orderBy, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, bool withSubfolders = false)
|
||||
{
|
||||
if (filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly or FilterType.SpreadsheetsOnly
|
||||
or FilterType.ArchiveOnly or FilterType.MediaOnly)
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
@ -167,8 +166,7 @@ internal class BoxFolderDao : BoxDaoBase, IFolderDao<string>
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetFoldersAsync(IEnumerable<string> folderIds, FilterType filterType = FilterType.None, bool subjectGroup = false, Guid? subjectID = null, string searchText = "", bool searchSubfolders = false, bool checkShare = true)
|
||||
{
|
||||
if (filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly or FilterType.SpreadsheetsOnly
|
||||
or FilterType.ArchiveOnly or FilterType.MediaOnly)
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
// 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
|
||||
|
||||
using ASC.Files.Core;
|
||||
|
||||
namespace ASC.Files.Thirdparty.Dropbox;
|
||||
|
||||
[Scope]
|
||||
@ -77,16 +79,16 @@ internal class DropboxFolderDao : DropboxDaoBase, IFolderDao<string>
|
||||
return GetRootFolderAsync(fileId);
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -99,16 +101,16 @@ internal class DropboxFolderDao : DropboxDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
|
@ -24,6 +24,8 @@
|
||||
// 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
|
||||
|
||||
using ASC.Files.Core;
|
||||
|
||||
namespace ASC.Files.Thirdparty.GoogleDrive;
|
||||
|
||||
[Scope]
|
||||
@ -74,16 +76,16 @@ internal class GoogleDriveFolderDao : GoogleDriveDaoBase, IFolderDao<string>
|
||||
return GetRootFolderAsync("");
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -96,16 +98,16 @@ internal class GoogleDriveFolderDao : GoogleDriveDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
|
@ -245,9 +245,6 @@ internal abstract class ThirdPartyProviderDao<T> : ThirdPartyProviderDao, IDispo
|
||||
protected RegexDaoSelectorBase<T> DaoSelector { get; set; }
|
||||
protected T ProviderInfo { get; set; }
|
||||
protected string PathPrefix { get; private set; }
|
||||
private readonly List<FilterType> _constraintFolderFilters =
|
||||
new() { FilterType.FilesOnly, FilterType.ByExtension, FilterType.DocumentsOnly, FilterType.ImagesOnly,
|
||||
FilterType.PresentationsOnly, FilterType.SpreadsheetsOnly, FilterType.ArchiveOnly, FilterType.MediaOnly };
|
||||
|
||||
protected abstract string Id { get; }
|
||||
|
||||
@ -412,7 +409,8 @@ internal abstract class ThirdPartyProviderDao<T> : ThirdPartyProviderDao, IDispo
|
||||
if (withoutTags)
|
||||
{
|
||||
return folders.Join(FilesDbContext.ThirdpartyIdMapping.ToAsyncEnumerable(), f => f.Id, m => m.Id, (folder, map) => new { folder, map.HashId })
|
||||
.WhereAwait(async r => !await FilesDbContext.TagLink.ToAsyncEnumerable().AnyAsync(t => t.EntryId == r.HashId))
|
||||
.WhereAwait(async r => !await FilesDbContext.TagLink.Join(FilesDbContext.Tag, l => l.TagId, t => t.Id, (link, tag) => new { link.EntryId, tag })
|
||||
.Where(r => r.tag.Type == TagType.Custom).ToAsyncEnumerable().AnyAsync(t => t.EntryId == r.HashId))
|
||||
.Select(r => r.folder);
|
||||
}
|
||||
|
||||
@ -430,24 +428,24 @@ internal abstract class ThirdPartyProviderDao<T> : ThirdPartyProviderDao, IDispo
|
||||
return filtered;
|
||||
}
|
||||
|
||||
protected IAsyncEnumerable<Folder<string>> FilterByRoomTypes(IAsyncEnumerable<Folder<string>> rooms, IEnumerable<FilterType> filterTypes)
|
||||
protected IAsyncEnumerable<Folder<string>> FilterByRoomType(IAsyncEnumerable<Folder<string>> rooms, FilterType filterType)
|
||||
{
|
||||
if (!filterTypes.Any() || filterTypes.Contains(FilterType.None))
|
||||
if (filterType == FilterType.None)
|
||||
{
|
||||
return rooms;
|
||||
}
|
||||
|
||||
var filter = filterTypes.Select(f => f switch
|
||||
var filter = filterType switch
|
||||
{
|
||||
FilterType.FillingFormsRooms => FolderType.FillingFormsRoom,
|
||||
FilterType.EditingRooms => FolderType.EditingRoom,
|
||||
FilterType.ReviewRooms => FolderType.ReviewRoom,
|
||||
FilterType.ReadOnlyRooms => FolderType.ReadOnlyRoom,
|
||||
FilterType.CustomRooms => FolderType.CustomRoom,
|
||||
_ => FolderType.CustomRoom
|
||||
}).ToHashSet();
|
||||
_ => FolderType.CustomRoom,
|
||||
};
|
||||
|
||||
return rooms.Where(f => filter.Contains(f.FolderType));
|
||||
return rooms.Where(f => f.FolderType == filter);
|
||||
}
|
||||
|
||||
protected IAsyncEnumerable<Folder<string>> FilterByOwner(IAsyncEnumerable<Folder<string>> rooms, Guid ownerId, bool withoutMe)
|
||||
@ -465,11 +463,10 @@ internal abstract class ThirdPartyProviderDao<T> : ThirdPartyProviderDao, IDispo
|
||||
return rooms;
|
||||
}
|
||||
|
||||
protected bool CheckForInvalidFilters(IEnumerable<FilterType> filterTypes)
|
||||
protected bool CheckInvalidFilter(FilterType filterType)
|
||||
{
|
||||
var intersection = filterTypes.Intersect(_constraintFolderFilters);
|
||||
|
||||
return !intersection.Any();
|
||||
return filterType is FilterType.FilesOnly or FilterType.ByExtension or FilterType.DocumentsOnly or FilterType.ImagesOnly or FilterType.PresentationsOnly
|
||||
or FilterType.SpreadsheetsOnly or FilterType.ArchiveOnly or FilterType.MediaOnly;
|
||||
}
|
||||
|
||||
protected abstract string MakeId(string path = null);
|
||||
|
@ -74,16 +74,16 @@ internal class OneDriveFolderDao : OneDriveDaoBase, IFolderDao<string>
|
||||
return GetRootFolderAsync(fileId);
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -96,16 +96,16 @@ internal class OneDriveFolderDao : OneDriveDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
|
@ -90,11 +90,11 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
|
||||
return folderDao.GetRootFolderByFileAsync(selector.ConvertId(fileId));
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public async IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
var selector = GetSelector(parentId);
|
||||
var folderDao = selector.GetFolderDao(parentId);
|
||||
var rooms = folderDao.GetRoomsAsync(selector.ConvertId(parentId), filterTypes, tags, ownerId, searchText, withSubfolders, withoutTags, withoutMe);
|
||||
var rooms = folderDao.GetRoomsAsync(selector.ConvertId(parentId), filterType, tags, ownerId, searchText, withSubfolders, withoutTags, withoutMe);
|
||||
var result = await rooms.Where(r => r != null).ToListAsync();
|
||||
|
||||
await SetSharedPropertyAsync(result);
|
||||
@ -105,7 +105,7 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
|
||||
}
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
var result = AsyncEnumerable.Empty<Folder<string>>();
|
||||
|
||||
@ -125,7 +125,7 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
|
||||
{
|
||||
var folderDao = selectorLocal.GetFolderDao(matchedId.FirstOrDefault());
|
||||
|
||||
return folderDao.GetRoomsAsync(matchedId.Select(selectorLocal.ConvertId).ToList(), filterTypes, tags, ownerId, searchText, withSubfolders, withoutTags, withoutMe);
|
||||
return folderDao.GetRoomsAsync(matchedId.Select(selectorLocal.ConvertId).ToList(), filterType, tags, ownerId, searchText, withSubfolders, withoutTags, withoutMe);
|
||||
})
|
||||
.Where(r => r != null));
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
// 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
|
||||
|
||||
using ASC.Files.Core;
|
||||
|
||||
namespace ASC.Files.Thirdparty.SharePoint;
|
||||
|
||||
[Scope]
|
||||
@ -80,16 +82,16 @@ internal class SharePointFolderDao : SharePointDaoBase, IFolderDao<string>
|
||||
return Task.FromResult(ProviderInfo.ToFolder(ProviderInfo.RootFolder));
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -102,16 +104,16 @@ internal class SharePointFolderDao : SharePointDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
|
@ -79,16 +79,16 @@ internal class SharpBoxFolderDao : SharpBoxDaoBase, IFolderDao<string>
|
||||
return Task.FromResult(ToFolder(RootFolder()));
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(string parentId, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var rooms = GetFoldersAsync(parentId);
|
||||
|
||||
rooms = FilterByRoomTypes(rooms, filterTypes);
|
||||
rooms = FilterByRoomType(rooms, filterType);
|
||||
rooms = FilterByOwner(rooms, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
@ -101,16 +101,16 @@ internal class SharpBoxFolderDao : SharpBoxDaoBase, IFolderDao<string>
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (!CheckForInvalidFilters(filterTypes))
|
||||
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, FilterType filterType, IEnumerable<string> tags, Guid ownerId, string searchText, bool withSubfolders, bool withoutTags, bool withoutMe)
|
||||
{
|
||||
if (CheckInvalidFilter(filterType))
|
||||
{
|
||||
return AsyncEnumerable.Empty<Folder<string>>();
|
||||
}
|
||||
|
||||
var folders = roomsIds.ToAsyncEnumerable().SelectAwait(async e => await GetFolderAsync(e).ConfigureAwait(false));
|
||||
|
||||
folders = FilterByRoomTypes(folders, filterTypes);
|
||||
folders = FilterByRoomType(folders, filterType);
|
||||
folders = FilterByOwner(folders, ownerId, withoutMe);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
|
@ -373,14 +373,7 @@ public class EntryManager
|
||||
_thumbnailSettings = thumbnailSettings;
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<FileEntry> Entries, int Total)> GetEntriesAsync<T>(Folder<T> parent, int from, int count, FilterType filterType, bool subjectGroup, Guid subjectId, string searchText,
|
||||
bool searchInContent, bool withSubfolders, OrderBy orderBy, SearchArea searchArea = SearchArea.Active, bool withoutTags = false, IEnumerable<string> tagNames = null, bool withoutMe = false)
|
||||
{
|
||||
return await GetEntriesAsync(parent, from, count, new[] { filterType }, subjectGroup, subjectId, searchText, searchInContent, withSubfolders, orderBy, searchArea, withoutTags,
|
||||
tagNames, withoutMe);
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<FileEntry> Entries, int Total)> GetEntriesAsync<T>(Folder<T> parent, int from, int count, IEnumerable<FilterType> filterTypes, bool subjectGroup, Guid subjectId,
|
||||
public async Task<(IEnumerable<FileEntry> Entries, int Total)> GetEntriesAsync<T>(Folder<T> parent, int from, int count, FilterType filterType, bool subjectGroup, Guid subjectId,
|
||||
string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy, SearchArea searchArea = SearchArea.Active, bool withoutTags = false, IEnumerable<string> tagNames = null,
|
||||
bool withoutMe = false)
|
||||
{
|
||||
@ -404,7 +397,7 @@ public class EntryManager
|
||||
var fileSecurity = _fileSecurity;
|
||||
var entries = Enumerable.Empty<FileEntry>();
|
||||
|
||||
searchInContent = searchInContent && !filterTypes.Contains(FilterType.ByExtension) && !Equals(parent.Id, _globalFolderHelper.FolderTrash);
|
||||
searchInContent = searchInContent && filterType != FilterType.ByExtension && !Equals(parent.Id, _globalFolderHelper.FolderTrash);
|
||||
|
||||
if (parent.FolderType == FolderType.Projects && parent.Id.Equals(await _globalFolderHelper.FolderProjectsAsync))
|
||||
{
|
||||
@ -509,7 +502,7 @@ public class EntryManager
|
||||
else if (parent.FolderType == FolderType.SHARE)
|
||||
{
|
||||
//share
|
||||
var shared = await fileSecurity.GetSharesForMeAsync(filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent, withSubfolders);
|
||||
var shared = await fileSecurity.GetSharesForMeAsync(filterType, subjectGroup, subjectId, searchText, searchInContent, withSubfolders);
|
||||
|
||||
entries = entries.Concat(shared);
|
||||
|
||||
@ -517,14 +510,14 @@ public class EntryManager
|
||||
}
|
||||
else if (parent.FolderType == FolderType.Recent)
|
||||
{
|
||||
var files = await GetRecentAsync(filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent);
|
||||
var files = await GetRecentAsync(filterType, subjectGroup, subjectId, searchText, searchInContent);
|
||||
entries = entries.Concat(files);
|
||||
|
||||
CalculateTotal();
|
||||
}
|
||||
else if (parent.FolderType == FolderType.Favorites)
|
||||
{
|
||||
var (files, folders) = await GetFavoritesAsync(filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent);
|
||||
var (files, folders) = await GetFavoritesAsync(filterType, subjectGroup, subjectId, searchText, searchInContent);
|
||||
|
||||
entries = entries.Concat(folders);
|
||||
entries = entries.Concat(files);
|
||||
@ -535,7 +528,7 @@ public class EntryManager
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var fileDao = _daoFactory.GetFileDao<T>();
|
||||
var files = await GetTemplatesAsync(folderDao, fileDao, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent);
|
||||
var files = await GetTemplatesAsync(folderDao, fileDao, filterType, subjectGroup, subjectId, searchText, searchInContent);
|
||||
entries = entries.Concat(files);
|
||||
|
||||
CalculateTotal();
|
||||
@ -544,14 +537,14 @@ public class EntryManager
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var fileDao = _daoFactory.GetFileDao<T>();
|
||||
var folders = await folderDao.GetFoldersAsync(parent.Id, orderBy, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
var folders = await folderDao.GetFoldersAsync(parent.Id, orderBy, filterType, subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
entries = entries.Concat(await fileSecurity.FilterReadAsync(folders));
|
||||
|
||||
var files = await fileDao.GetFilesAsync(parent.Id, orderBy, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent, withSubfolders).ToListAsync();
|
||||
var files = await fileDao.GetFilesAsync(parent.Id, orderBy, filterType, subjectGroup, subjectId, searchText, searchInContent, withSubfolders).ToListAsync();
|
||||
entries = entries.Concat(await fileSecurity.FilterReadAsync(files));
|
||||
|
||||
//share
|
||||
var shared = await fileSecurity.GetPrivacyForMeAsync(filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent, withSubfolders);
|
||||
var shared = await fileSecurity.GetPrivacyForMeAsync(filterType, subjectGroup, subjectId, searchText, searchInContent, withSubfolders);
|
||||
|
||||
entries = entries.Concat(shared);
|
||||
|
||||
@ -559,7 +552,7 @@ public class EntryManager
|
||||
}
|
||||
else if (parent.FolderType == FolderType.VirtualRooms && !parent.ProviderEntry)
|
||||
{
|
||||
entries = await fileSecurity.GetVirtualRoomsAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
entries = await fileSecurity.GetVirtualRoomsAsync(filterType, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, withoutMe);
|
||||
|
||||
CalculateTotal();
|
||||
}
|
||||
@ -570,17 +563,17 @@ public class EntryManager
|
||||
withSubfolders = false;
|
||||
}
|
||||
|
||||
var folders = await _daoFactory.GetFolderDao<T>().GetFoldersAsync(parent.Id, orderBy, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
var folders = await _daoFactory.GetFolderDao<T>().GetFoldersAsync(parent.Id, orderBy, filterType, subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
entries = entries.Concat(await fileSecurity.FilterReadAsync(folders));
|
||||
|
||||
var files = await _daoFactory.GetFileDao<T>().GetFilesAsync(parent.Id, orderBy, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent, withSubfolders).ToListAsync();
|
||||
var files = await _daoFactory.GetFileDao<T>().GetFilesAsync(parent.Id, orderBy, filterType, subjectGroup, subjectId, searchText, searchInContent, withSubfolders).ToListAsync();
|
||||
entries = entries.Concat(await fileSecurity.FilterReadAsync(files));
|
||||
|
||||
if (filterTypes.FirstOrDefault() == FilterType.None || filterTypes.FirstOrDefault() == FilterType.FoldersOnly)
|
||||
if (filterType == FilterType.None || filterType == FilterType.FoldersOnly)
|
||||
{
|
||||
var folderList = await GetThirpartyFoldersAsync(parent, searchText);
|
||||
|
||||
var thirdPartyFolder = FilterEntries(folderList, filterTypes.FirstOrDefault(), subjectGroup, subjectId, searchText, searchInContent);
|
||||
var thirdPartyFolder = FilterEntries(folderList, filterType, subjectGroup, subjectId, searchText, searchInContent);
|
||||
entries = entries.Concat(thirdPartyFolder);
|
||||
}
|
||||
}
|
||||
|
@ -649,16 +649,14 @@ public class VirtualRoomsCommonController : ApiControllerBase
|
||||
/// Virtual Rooms content
|
||||
/// </returns>
|
||||
[HttpGet("rooms")]
|
||||
public async Task<FolderContentDto<int>> GetRoomsFolderAsync(string types, string subjectId, bool searchInContent, bool withSubfolders, SearchArea searchArea, bool withoutTags, string tags,
|
||||
public async Task<FolderContentDto<int>> GetRoomsFolderAsync(RoomType type, string subjectId, bool searchInContent, bool withSubfolders, SearchArea searchArea, bool withoutTags, string tags,
|
||||
bool withoutMe)
|
||||
{
|
||||
ErrorIfNotDocSpace();
|
||||
|
||||
var parentId = await _globalFolderHelper.GetFolderVirtualRooms<int>();
|
||||
|
||||
var roomTypes = !string.IsNullOrEmpty(types) ? JsonSerializer.Deserialize<IEnumerable<RoomType>>(types) : null;
|
||||
|
||||
var filterTypes = roomTypes != null ? roomTypes.Select(t => t switch
|
||||
var filterType = type switch
|
||||
{
|
||||
RoomType.FillingFormsRoom => FilterType.FillingFormsRooms,
|
||||
RoomType.ReadOnlyRoom => FilterType.ReadOnlyRooms,
|
||||
@ -666,7 +664,7 @@ public class VirtualRoomsCommonController : ApiControllerBase
|
||||
RoomType.ReviewRoom => FilterType.ReviewRooms,
|
||||
RoomType.CustomRoom => FilterType.CustomRooms,
|
||||
_ => FilterType.None
|
||||
}) : new[] { FilterType.None };
|
||||
};
|
||||
|
||||
var tagNames = !string.IsNullOrEmpty(tags) ? JsonSerializer.Deserialize<IEnumerable<string>>(tags) : null;
|
||||
|
||||
@ -680,7 +678,7 @@ public class VirtualRoomsCommonController : ApiControllerBase
|
||||
var count = Convert.ToInt32(_apiContext.Count);
|
||||
var filterValue = _apiContext.FilterValue;
|
||||
|
||||
var content = await _fileStorageService.GetFolderItemsAsync(parentId, startIndex, count, filterTypes, false, subjectId, filterValue,
|
||||
var content = await _fileStorageService.GetFolderItemsAsync(parentId, startIndex, count, filterType, false, subjectId, filterValue,
|
||||
searchInContent, withSubfolders, orderBy, searchArea, withoutTags, tagNames, withoutMe);
|
||||
|
||||
var dto = await _folderContentDtoHelper.GetAsync(content, startIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user