Skip to content

Commit

Permalink
Quota: add room filtering by quota for all user types
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayRechkin committed Nov 13, 2024
1 parent b1c6d97 commit 7600d7e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Configuration/ProductEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private async Task<Dictionary<string, bool>> GetUserRoomsWithRoleAsync(Guid user
var virtualRoomsFolderId = await _globalFolder.GetFolderVirtualRoomsAsync(_daoFactory);
var archiveFolderId = await _globalFolder.GetFolderArchiveAsync(_daoFactory);

var rooms = await folderDao.GetRoomsAsync(new List<int> { virtualRoomsFolderId, archiveFolderId }, null, null, Guid.Empty, null, false, false, false, ProviderFilter.None, SubjectFilter.Owner, null).ToListAsync();
var rooms = await folderDao.GetRoomsAsync(new List<int> { virtualRoomsFolderId, archiveFolderId }, null, null, Guid.Empty, null, false, false, false, ProviderFilter.None, SubjectFilter.Owner, null, null).ToListAsync();

foreach (var room in rooms)
{
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Core/Dao/Interfaces/IFolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ IAsyncEnumerable<Folder<T>> GetRoomsAsync(IEnumerable<T> parentsIds, IEnumerable
bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, QuotaFilter quotaFilter);

IAsyncEnumerable<Folder<T>> GetRoomsAsync(IEnumerable<T> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders,
bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null);
bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null, QuotaFilter quotaFilter = QuotaFilter.All);

IAsyncEnumerable<Folder<T>> GetProviderBasedRoomsAsync(SearchArea searchArea, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withoutTags,
bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds);
Expand Down
5 changes: 3 additions & 2 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public async IAsyncEnumerable<Folder<int>> GetRoomsAsync(
ProviderFilter provider,
SubjectFilter subjectFilter,
IEnumerable<string> subjectEntriesIds,
IEnumerable<int> parentsIds)
IEnumerable<int> parentsIds,
QuotaFilter quotaFilter)
{
if (CheckInvalidFilters(filterTypes) || provider != ProviderFilter.None)
{
Expand All @@ -216,7 +217,7 @@ public async IAsyncEnumerable<Folder<int>> GetRoomsAsync(
await using var filesDbContext = await _dbContextFactory.CreateDbContextAsync();
var q = await GetFolderQuery(filesDbContext, f => roomsIds.Contains(f.Id) || (f.CreateBy == _authContext.CurrentAccount.ID && parentsIds != null && parentsIds.Contains(f.ParentId)));

q = !withSubfolders ? BuildRoomsQuery(filesDbContext, q, filter, tags, subjectId, searchByTags, withoutTags, searchByTypes, false, excludeSubject, subjectFilter, subjectEntriesIds)
q = !withSubfolders ? BuildRoomsQuery(filesDbContext, q, filter, tags, subjectId, searchByTags, withoutTags, searchByTypes, false, excludeSubject, subjectFilter, subjectEntriesIds, quotaFilter)
: await BuildRoomsWithSubfoldersQuery(filesDbContext, roomsIds, filter, tags, searchByTags, searchByTypes, withoutTags, excludeSubject, subjectId, subjectFilter, subjectEntriesIds);

if (!string.IsNullOrEmpty(searchText))
Expand Down
9 changes: 5 additions & 4 deletions products/ASC.Files/Core/Core/Security/FileSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,12 +1812,12 @@ public async Task<List<FileEntry>> GetVirtualRoomsAsync(

if (isAdmin)
{
return await GetAllVirtualRoomsAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, excludeSubject, provider,
return await GetAllVirtualRoomsAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, excludeSubject, provider,
subjectFilter, subjectEntries, quotaFilter, storageFilter, internalRoomsRecords, thirdPartyRoomsRecords);
}

return await GetVirtualRoomsForMeAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, excludeSubject, provider,
subjectFilter, subjectEntries, storageFilter, internalRoomsRecords, thirdPartyRoomsRecords);
return await GetVirtualRoomsForMeAsync(filterTypes, subjectId, searchText, searchInContent, withSubfolders, searchArea, withoutTags, tagNames, excludeSubject, provider,
subjectFilter, subjectEntries, quotaFilter, storageFilter, internalRoomsRecords, thirdPartyRoomsRecords);
}

private async Task<List<FileEntry>> GetAllVirtualRoomsAsync(
Expand Down Expand Up @@ -1930,6 +1930,7 @@ private async Task<List<FileEntry>> GetVirtualRoomsForMeAsync(
ProviderFilter provider,
SubjectFilter subjectFilter,
IEnumerable<string> subjectEntries,
QuotaFilter quotaFilter,
StorageFilter storageFilter,
Dictionary<int, FileShareRecord<int>> internalRecords,
Dictionary<string, FileShareRecord<string>> thirdPartyRecords)
Expand All @@ -1950,7 +1951,7 @@ private async Task<List<FileEntry>> GetVirtualRoomsForMeAsync(
var rooms = storageFilter == StorageFilter.ThirdParty
? []
: await folderDao.GetRoomsAsync(internalRecords.Keys, filterTypes, tagNames, subjectId, search, withSubfolders, withoutTags, excludeSubject, provider,
subjectFilter, subjectEntries, rootFoldersIds).Where(r => Filter(r, internalRecords)).ToListAsync();
subjectFilter, subjectEntries, rootFoldersIds, quotaFilter).Where(r => Filter(r, internalRecords)).ToListAsync();

var thirdPartyRooms = storageFilter == StorageFilter.Internal
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task<Folder<string>> GetRootFolderByFileAsync(string fileId)
return await ResolveParentAsync(folder);
}

public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders, bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null)
public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders, bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null, QuotaFilter quotaFilter = QuotaFilter.All)
{
var result = AsyncEnumerable.Empty<Folder<string>>();

Expand All @@ -100,7 +100,7 @@ public IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsI
var folderDao = selectorLocal.GetFolderDao(matchedId.FirstOrDefault());

return folderDao.GetRoomsAsync(matchedId.Select(selectorLocal.ConvertId).ToList(), filterTypes, tags, subjectId, searchText, withSubfolders, withoutTags,
excludeSubject, provider, subjectFilter, subjectEntriesIds);
excludeSubject, provider, subjectFilter, subjectEntriesIds, quotaFilter);
})
.Where(r => r != null))
.SelectAwait(async r => await ResolveParentAsync(r));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Task<Folder<string>> GetRootFolderByFileAsync(string fileId)
return Task.FromResult(SharePointProviderInfo.ToFolder(SharePointProviderInfo.RootFolder));
}

public async IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders, bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null)
public async IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders, bool withoutTags, bool excludeSubject, ProviderFilter provider, SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null, QuotaFilter quotaFilter = QuotaFilter.All)
{
if (CheckInvalidFilters(filterTypes) || (provider != ProviderFilter.None && provider != SharePointProviderInfo.ProviderFilter))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Task<Folder<string>> GetRootFolderByFileAsync(string fileId)
}

public async IAsyncEnumerable<Folder<string>> GetRoomsAsync(IEnumerable<string> roomsIds, IEnumerable<FilterType> filterTypes, IEnumerable<string> tags, Guid subjectId, string searchText, bool withSubfolders, bool withoutTags, bool excludeSubject, ProviderFilter provider,
SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null)
SubjectFilter subjectFilter, IEnumerable<string> subjectEntriesIds, IEnumerable<int> parentsIds = null, QuotaFilter quotaFilter = QuotaFilter.All)
{
if (dao.CheckInvalidFilters(filterTypes) || (provider != ProviderFilter.None && provider != _providerInfo.ProviderFilter))
{
Expand Down

0 comments on commit 7600d7e

Please sign in to comment.