Files: added gettings user rooms
This commit is contained in:
parent
efb225a3d8
commit
70ec83fe06
@ -899,6 +899,48 @@ public class FileSecurity : IFileSecurity
|
||||
return entries.Where(x => string.IsNullOrEmpty(x.Error)).Cast<FileEntry>().ToList();
|
||||
}
|
||||
|
||||
public async Task<List<FileEntry>> GetVirtualRoomsForMeAsync()
|
||||
{
|
||||
var securityDao = _daoFactory.GetSecurityDao<int>();
|
||||
var subjects = GetUserSubjects(_authContext.CurrentAccount.ID);
|
||||
var records = await securityDao.GetSharesAsync(subjects);
|
||||
|
||||
var result = new List<FileEntry>();
|
||||
result.AddRange(await GetVirtualRoomsForMeAsync<int>(records.Where(r => r.EntryId.GetType() == typeof(int)), subjects));
|
||||
result.AddRange(await GetVirtualRoomsForMeAsync<string>(records.Where(r => r.EntryId.GetType() == typeof(string)), subjects));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<List<FileEntry>> GetVirtualRoomsForMeAsync<T>(IEnumerable<FileShareRecord> records, List<Guid> subjects)
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var folderIds = new Dictionary<T, FileShare>();
|
||||
|
||||
var recordGroup = records.GroupBy(r => new { r.EntryId, r.EntryType }, (key, group) => new
|
||||
{
|
||||
firstRecord = group.OrderBy(r => r, new SubjectComparer(subjects))
|
||||
.ThenByDescending(r => r.Share, new FileShareRecord.ShareComparer())
|
||||
.First()
|
||||
});
|
||||
|
||||
foreach (var record in recordGroup)
|
||||
{
|
||||
if (!folderIds.ContainsKey((T)record.firstRecord.EntryId))
|
||||
{
|
||||
folderIds.Add((T)record.firstRecord.EntryId, record.firstRecord.Share);
|
||||
}
|
||||
}
|
||||
|
||||
var entries = new List<FileEntry>();
|
||||
|
||||
var folders = await folderDao.GetFoldersAsync(folderIds.Keys).Where(f => f.RootFolderType == FolderType.VirtualRooms).ToListAsync();
|
||||
|
||||
entries.AddRange(folders);
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
public async Task<List<FileEntry>> GetPrivacyForMeAsync(FilterType filterType, bool subjectGroup, Guid subjectID, string searchText = "", bool searchInContent = false, bool withSubfolders = false)
|
||||
{
|
||||
var securityDao = _daoFactory.GetSecurityDao<int>();
|
||||
|
@ -252,7 +252,7 @@ public class EntryManager
|
||||
{
|
||||
private const string UpdateList = "filesUpdateList";
|
||||
|
||||
private ICache _cache;
|
||||
private readonly ICache _cache;
|
||||
private readonly FileTrackerHelper _fileTracker;
|
||||
private readonly EntryStatusManager _entryStatusManager;
|
||||
private readonly IDaoFactory _daoFactory;
|
||||
@ -278,6 +278,7 @@ public class EntryManager
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ILog _logger;
|
||||
private readonly IHttpClientFactory _clientFactory;
|
||||
private readonly Global _global;
|
||||
|
||||
public EntryManager(
|
||||
IDaoFactory daoFactory,
|
||||
@ -305,7 +306,8 @@ public class EntryManager
|
||||
ICache cache,
|
||||
FileTrackerHelper fileTracker,
|
||||
EntryStatusManager entryStatusManager,
|
||||
IHttpClientFactory clientFactory)
|
||||
IHttpClientFactory clientFactory,
|
||||
Global global)
|
||||
{
|
||||
_daoFactory = daoFactory;
|
||||
_fileSecurity = fileSecurity;
|
||||
@ -333,6 +335,7 @@ public class EntryManager
|
||||
_fileTracker = fileTracker;
|
||||
_entryStatusManager = entryStatusManager;
|
||||
_clientFactory = clientFactory;
|
||||
_global = global;
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<FileEntry> Entries, int Total)> GetEntriesAsync<T>(Folder<T> parent, int from, int count, FilterType filter, bool subjectGroup, Guid subjectId, string searchText, bool searchInContent, bool withSubfolders, OrderBy orderBy)
|
||||
@ -510,6 +513,22 @@ public class EntryManager
|
||||
|
||||
CalculateTotal();
|
||||
}
|
||||
else if (parent.FolderType == FolderType.VirtualRooms)
|
||||
{
|
||||
if (_global.IsAdministrator)
|
||||
{
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var folders = await folderDao.GetFoldersAsync(parent.Id, orderBy, filter, subjectGroup, subjectId, searchText, withSubfolders).ToListAsync();
|
||||
|
||||
entries = entries.Concat(folders);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries = await fileSecurity.GetVirtualRoomsForMeAsync();
|
||||
}
|
||||
|
||||
CalculateTotal();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent.FolderType == FolderType.TRASH)
|
||||
|
Loading…
Reference in New Issue
Block a user