Files: fix delete and readHistory for archive, added changeHistory
This commit is contained in:
parent
fa43e3deaf
commit
580c6688a3
@ -724,11 +724,21 @@ public class FileSecurity : IFileSecurity
|
||||
|
||||
if ((e.RootFolderType == FolderType.VirtualRooms || e.RootFolderType == FolderType.Archive) && !isUser)
|
||||
{
|
||||
if (e.RootFolderType == FolderType.Archive && action != FilesSecurityActions.Read && action != FilesSecurityActions.Delete && action != FilesSecurityActions.RoomEdit)
|
||||
if (e.RootFolderType == FolderType.Archive &&
|
||||
action != FilesSecurityActions.Read &&
|
||||
action != FilesSecurityActions.Delete &&
|
||||
action != FilesSecurityActions.RoomEdit &&
|
||||
action != FilesSecurityActions.ReadHistory
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action == FilesSecurityActions.Delete && e.RootFolderType == FolderType.Archive && isDocSpaceAdmin)
|
||||
{
|
||||
return folder != null && DocSpaceHelper.IsRoom(folder.FolderType);
|
||||
}
|
||||
|
||||
if (isDocSpaceAdmin || e.CreateBy == userId)
|
||||
{
|
||||
return true;
|
||||
@ -741,6 +751,7 @@ public class FileSecurity : IFileSecurity
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (e.RootFolderType == FolderType.ThirdpartyBackup && isDocSpaceAdmin)
|
||||
@ -748,11 +759,6 @@ public class FileSecurity : IFileSecurity
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == FilesSecurityActions.Delete && e.RootFolderType == FolderType.Archive && isDocSpaceAdmin)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action == FilesSecurityActions.RoomEdit && e.RootFolderType == FolderType.Archive && isDocSpaceAdmin)
|
||||
{
|
||||
return true;
|
||||
@ -829,8 +835,13 @@ public class FileSecurity : IFileSecurity
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (action == FilesSecurityActions.Edit && (e.Access == FileShare.ReadWrite || e.Access == FileShare.RoomAdmin || e.Access == FileShare.Editing) && e.RootFolderType != FolderType.Archive)
|
||||
else if ((action == FilesSecurityActions.Edit || action == FilesSecurityActions.ChangeHistory) && (e.Access == FileShare.ReadWrite || e.Access == FileShare.RoomAdmin || e.Access == FileShare.Editing) && e.RootFolderType != FolderType.Archive)
|
||||
{
|
||||
if (action == FilesSecurityActions.ChangeHistory)
|
||||
{
|
||||
return file != null && !file.Encrypted;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (action == FilesSecurityActions.Rename && (e.Access == FileShare.ReadWrite || e.Access == FileShare.RoomAdmin) && e.RootFolderType != FolderType.Archive)
|
||||
@ -845,7 +856,7 @@ public class FileSecurity : IFileSecurity
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (action == FilesSecurityActions.ReadHistory && (e.Access == FileShare.RoomAdmin || e.Access == FileShare.Editing) && e.RootFolderType != FolderType.Archive)
|
||||
else if (action == FilesSecurityActions.ReadHistory && (e.Access == FileShare.RoomAdmin || e.Access == FileShare.Editing))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1289,7 +1300,7 @@ public class FileSecurity : IFileSecurity
|
||||
var folderDao = _daoFactory.GetFolderDao<T>();
|
||||
var fileDao = _daoFactory.GetFileDao<T>();
|
||||
var securityDao = _daoFactory.GetSecurityDao<T>();
|
||||
|
||||
|
||||
var fileIds = new Dictionary<T, FileShare>();
|
||||
var folderIds = new Dictionary<T, FileShare>();
|
||||
|
||||
@ -1307,24 +1318,24 @@ public class FileSecurity : IFileSecurity
|
||||
if (!folderIds.ContainsKey((T)r.firstRecord.EntryId))
|
||||
{
|
||||
folderIds.Add((T)r.firstRecord.EntryId, r.firstRecord.Share);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fileIds.ContainsKey((T)r.firstRecord.EntryId))
|
||||
{
|
||||
fileIds.Add((T)r.firstRecord.EntryId, r.firstRecord.Share);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var entries = new List<FileEntry<T>>();
|
||||
|
||||
|
||||
if (filterType != FilterType.FoldersOnly)
|
||||
{
|
||||
var files = fileDao.GetFilesFilteredAsync(fileIds.Keys.ToArray(), filterType, subjectGroup, subjectID, searchText, searchInContent);
|
||||
var share = await _globalFolder.GetFolderShareAsync<T>(_daoFactory);
|
||||
|
||||
|
||||
await foreach (var x in files)
|
||||
{
|
||||
if (fileIds.TryGetValue(x.Id, out var access))
|
||||
@ -1336,11 +1347,11 @@ public class FileSecurity : IFileSecurity
|
||||
entries.Add(x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (filterType == FilterType.None || filterType == FilterType.FoldersOnly)
|
||||
{
|
||||
IAsyncEnumerable<FileEntry<T>> folders = folderDao.GetFoldersAsync(folderIds.Keys, filterType, subjectGroup, subjectID, searchText, withSubfolders, false);
|
||||
|
||||
|
||||
if (withSubfolders)
|
||||
{
|
||||
folders = FilterReadAsync(folders);
|
||||
@ -1359,38 +1370,38 @@ public class FileSecurity : IFileSecurity
|
||||
entries.Add(folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (filterType != FilterType.FoldersOnly && withSubfolders)
|
||||
{
|
||||
IAsyncEnumerable<FileEntry<T>> filesInSharedFolders = fileDao.GetFilesAsync(folderIds.Keys, filterType, subjectGroup, subjectID, searchText, searchInContent);
|
||||
filesInSharedFolders = FilterReadAsync(filesInSharedFolders);
|
||||
entries.AddRange(await filesInSharedFolders.Distinct().ToListAsync());
|
||||
}
|
||||
|
||||
|
||||
var data = entries.Where(f =>
|
||||
f.RootFolderType == FolderType.USER // show users files
|
||||
&& f.RootCreateBy != _authContext.CurrentAccount.ID // don't show my files
|
||||
);
|
||||
|
||||
|
||||
if (_userManager.IsUser(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
data = data.Where(r => !r.ProviderEntry);
|
||||
}
|
||||
|
||||
|
||||
var failedEntries = entries.Where(x => !string.IsNullOrEmpty(x.Error));
|
||||
var failedRecords = new List<FileShareRecord>();
|
||||
|
||||
|
||||
foreach (var failedEntry in failedEntries)
|
||||
{
|
||||
var entryType = failedEntry.FileEntryType;
|
||||
|
||||
|
||||
var failedRecord = records.First(x => x.EntryId.Equals(failedEntry.Id) && x.EntryType == entryType);
|
||||
|
||||
|
||||
failedRecord.Share = FileShare.None;
|
||||
|
||||
|
||||
failedRecords.Add(failedRecord);
|
||||
}
|
||||
|
||||
|
||||
if (failedRecords.Count > 0)
|
||||
{
|
||||
await securityDao.DeleteShareRecordsAsync(failedRecords);
|
||||
@ -1584,6 +1595,7 @@ public class FileSecurity : IFileSecurity
|
||||
RoomEdit,
|
||||
Rename,
|
||||
ReadHistory,
|
||||
Lock
|
||||
Lock,
|
||||
ChangeHistory
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user