Files: added aces fileter
This commit is contained in:
parent
296fe44c46
commit
7e9719828f
@ -2044,7 +2044,7 @@ public class FileStorageService<T> //: IFileStorageService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var changed = await _fileSharingAceHelper.SetAceObjectAsync(aceCollection.Aces, entry, notify, aceCollection.Message);
|
var changed = await _fileSharingAceHelper.SetAceObjectAsync(aceCollection.Aces, entry, notify, aceCollection.Message, _coreBaseSettings.DocSpace);
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
_filesMessageService.Send(entry, GetHttpHeaders(),
|
_filesMessageService.Send(entry, GetHttpHeaders(),
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
// 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
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||||
|
|
||||||
|
using ASC.Files.Core.Helpers;
|
||||||
|
|
||||||
namespace ASC.Web.Files.Utils;
|
namespace ASC.Web.Files.Utils;
|
||||||
|
|
||||||
[Scope]
|
[Scope]
|
||||||
@ -40,6 +42,7 @@ public class FileSharingAceHelper<T>
|
|||||||
private readonly GlobalFolderHelper _globalFolderHelper;
|
private readonly GlobalFolderHelper _globalFolderHelper;
|
||||||
private readonly FileSharingHelper _fileSharingHelper;
|
private readonly FileSharingHelper _fileSharingHelper;
|
||||||
private readonly FileTrackerHelper _fileTracker;
|
private readonly FileTrackerHelper _fileTracker;
|
||||||
|
private readonly FileSecurityCommon _fileSecurityCommon;
|
||||||
|
|
||||||
public FileSharingAceHelper(
|
public FileSharingAceHelper(
|
||||||
FileSecurity fileSecurity,
|
FileSecurity fileSecurity,
|
||||||
@ -52,7 +55,8 @@ public class FileSharingAceHelper<T>
|
|||||||
NotifyClient notifyClient,
|
NotifyClient notifyClient,
|
||||||
GlobalFolderHelper globalFolderHelper,
|
GlobalFolderHelper globalFolderHelper,
|
||||||
FileSharingHelper fileSharingHelper,
|
FileSharingHelper fileSharingHelper,
|
||||||
FileTrackerHelper fileTracker)
|
FileTrackerHelper fileTracker,
|
||||||
|
FileSecurityCommon fileSecurityCommon)
|
||||||
{
|
{
|
||||||
_fileSecurity = fileSecurity;
|
_fileSecurity = fileSecurity;
|
||||||
_coreBaseSettings = coreBaseSettings;
|
_coreBaseSettings = coreBaseSettings;
|
||||||
@ -65,9 +69,10 @@ public class FileSharingAceHelper<T>
|
|||||||
_globalFolderHelper = globalFolderHelper;
|
_globalFolderHelper = globalFolderHelper;
|
||||||
_fileSharingHelper = fileSharingHelper;
|
_fileSharingHelper = fileSharingHelper;
|
||||||
_fileTracker = fileTracker;
|
_fileTracker = fileTracker;
|
||||||
|
_fileSecurityCommon = fileSecurityCommon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SetAceObjectAsync(List<AceWrapper> aceWrappers, FileEntry<T> entry, bool notify, string message)
|
public async Task<bool> SetAceObjectAsync(List<AceWrapper> aceWrappers, FileEntry<T> entry, bool notify, string message, bool handleForRooms = false)
|
||||||
{
|
{
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
@ -85,6 +90,8 @@ public class FileSharingAceHelper<T>
|
|||||||
var recipients = new Dictionary<Guid, FileShare>();
|
var recipients = new Dictionary<Guid, FileShare>();
|
||||||
var usersWithoutRight = new List<Guid>();
|
var usersWithoutRight = new List<Guid>();
|
||||||
var changed = false;
|
var changed = false;
|
||||||
|
|
||||||
|
aceWrappers = handleForRooms ? FilterAndProcessForRooms(entry, aceWrappers) : aceWrappers;
|
||||||
|
|
||||||
foreach (var w in aceWrappers.OrderByDescending(ace => ace.SubjectGroup))
|
foreach (var w in aceWrappers.OrderByDescending(ace => ace.SubjectGroup))
|
||||||
{
|
{
|
||||||
@ -220,6 +227,60 @@ public class FileSharingAceHelper<T>
|
|||||||
await _fileMarker.RemoveMarkAsNewAsync(entry);
|
await _fileMarker.RemoveMarkAsNewAsync(entry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<AceWrapper> FilterAndProcessForRooms(FileEntry<T> entry, List<AceWrapper> aceWrappers)
|
||||||
|
{
|
||||||
|
if (entry.FileEntryType == FileEntryType.File)
|
||||||
|
{
|
||||||
|
return aceWrappers;
|
||||||
|
}
|
||||||
|
|
||||||
|
var folderType = ((IFolder)entry).FolderType;
|
||||||
|
|
||||||
|
if (folderType != FolderType.FillingFormsRoom && folderType != FolderType.EditingRoom
|
||||||
|
&& folderType != FolderType.ReadOnlyRoom && folderType != FolderType.ReviewRoom
|
||||||
|
&& folderType != FolderType.CustomRoom)
|
||||||
|
{
|
||||||
|
return aceWrappers;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new List<AceWrapper>(aceWrappers.Count);
|
||||||
|
|
||||||
|
var isAdmin = _fileSecurityCommon.IsAdministrator(_authContext.CurrentAccount.ID);
|
||||||
|
var isRoomManager = !isAdmin ? false : true;
|
||||||
|
|
||||||
|
foreach (var ace in aceWrappers)
|
||||||
|
{
|
||||||
|
if (ace.SubjectGroup)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RoomTemplateValidator.Validate(ace.Share, folderType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ace.Share == FileShare.RoomManager && isAdmin)
|
||||||
|
{
|
||||||
|
result.Add(ace);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ace.Share == FileShare.None || ace.Share == FileShare.Restrict ) && isAdmin)
|
||||||
|
{
|
||||||
|
result.Add(ace);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ace.Share != FileShare.RoomManager && isRoomManager)
|
||||||
|
{
|
||||||
|
result.Add(ace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Scope]
|
[Scope]
|
||||||
|
Loading…
Reference in New Issue
Block a user