Files: added room filtering by provider type

This commit is contained in:
Maksim Chegulov 2022-10-03 11:45:02 +03:00
parent 7164d4b25c
commit 8f7216d506
13 changed files with 94 additions and 5 deletions

View File

@ -43,6 +43,14 @@ public enum RoomFilterType
ReadOnlyRoomOnly = 4,
CustomRoomOnly = 5,
FoldersOnly = 6,
BoxOnly = 7,
DropboxV2Only = 8,
GoogleDriveOnly = 9,
OneDriveOnly = 10,
SharePointOnly = 11,
WebDavOnly = 12,
kDriveOnly = 13,
YandexOnly = 14,
}
public class CreateRoomRequestDto

View File

@ -9,7 +9,7 @@
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.htm
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//

View File

@ -1566,7 +1566,15 @@ internal class FolderDao : AbstractDao, IFolderDao<int>
FilterType.PresentationsOnly or
FilterType.SpreadsheetsOnly or
FilterType.ArchiveOnly or
FilterType.MediaOnly;
FilterType.MediaOnly or
FilterType.BoxOnly or
FilterType.DropboxV2Only or
FilterType.GoogleDriveOnly or
FilterType.OneDriveOnly or
FilterType.SharePointOnly or
FilterType.WebDavOnly or
FilterType.kDriveOnly or
FilterType.YandexOnly;
}
private FolderType GetRoomTypeFilter(FilterType filterType)

View File

@ -47,4 +47,12 @@ public enum FilterType
[EnumMember] CustomRooms = 17,
[EnumMember] OFormTemplateOnly = 18,
[EnumMember] OFormOnly = 19,
[EnumMember] BoxOnly = 20,
[EnumMember] DropboxV2Only = 21,
[EnumMember] GoogleDriveOnly = 22,
[EnumMember] OneDriveOnly = 23,
[EnumMember] SharePointOnly = 24,
[EnumMember] WebDavOnly = 25,
[EnumMember] kDriveOnly = 26,
[EnumMember] YandexOnly = 27,
}

View File

@ -529,4 +529,10 @@ internal class BoxFolderDao : BoxDaoBase, IFolderDao<string>
return chunkedUpload ? storageMaxUploadSize : Math.Min(storageMaxUploadSize, _setupInfo.AvailableFileSize);
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.GoogleDriveOnly or FilterType.DropboxV2Only or FilterType.kDriveOnly or FilterType.SharePointOnly
or FilterType.YandexOnly or FilterType.WebDavOnly or FilterType.OneDriveOnly;
}
}

View File

@ -519,4 +519,10 @@ internal class DropboxFolderDao : DropboxDaoBase, IFolderDao<string>
return chunkedUpload ? storageMaxUploadSize : Math.Min(storageMaxUploadSize, _setupInfo.AvailableFileSize);
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.BoxOnly or FilterType.GoogleDriveOnly or FilterType.kDriveOnly or FilterType.SharePointOnly
or FilterType.YandexOnly or FilterType.WebDavOnly or FilterType.OneDriveOnly;
}
}

View File

@ -520,4 +520,10 @@ internal class GoogleDriveFolderDao : GoogleDriveDaoBase, IFolderDao<string>
return chunkedUpload ? storageMaxUploadSize : Math.Min(storageMaxUploadSize, _setupInfo.AvailableFileSize);
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.BoxOnly or FilterType.DropboxV2Only or FilterType.kDriveOnly or FilterType.SharePointOnly
or FilterType.YandexOnly or FilterType.WebDavOnly or FilterType.OneDriveOnly;
}
}

View File

@ -466,7 +466,7 @@ internal abstract class ThirdPartyProviderDao<T> : ThirdPartyProviderDao, IDispo
return rooms;
}
protected bool CheckInvalidFilter(FilterType filterType)
public virtual bool CheckInvalidFilter(FilterType filterType)
{
return filterType is
FilterType.FilesOnly or

View File

@ -532,4 +532,10 @@ internal class OneDriveFolderDao : OneDriveDaoBase, IFolderDao<string>
return chunkedUpload ? storageMaxUploadSize : Math.Min(storageMaxUploadSize, _setupInfo.AvailableFileSize);
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.BoxOnly or FilterType.DropboxV2Only or FilterType.kDriveOnly or FilterType.SharePointOnly
or FilterType.YandexOnly or FilterType.WebDavOnly or FilterType.GoogleDriveOnly;
}
}

View File

@ -95,7 +95,8 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
var selector = GetSelector(parentId);
var folderDao = selector.GetFolderDao(parentId);
var rooms = folderDao.GetRoomsAsync(selector.ConvertId(parentId), filterType, tags, subjectId, searchText, withSubfolders, withoutTags, excludeSubject);
var result = await rooms.Where(r => r != null).ToListAsync();
var result = await FilterByProviders(rooms.Where(r => r != null), filterType).ToListAsync();
await SetSharedPropertyAsync(result);
@ -130,6 +131,8 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
.Where(r => r != null));
}
result = FilterByProviders(result, filterType);
return result.Distinct();
}
@ -435,4 +438,22 @@ internal class ProviderFolderDao : ProviderDaoBase, IFolderDao<string>
return storageMaxUploadSize;
}
private IAsyncEnumerable<Folder<string>> FilterByProviders(IAsyncEnumerable<Folder<string>> folders, FilterType filterType)
{
if (filterType != FilterType.WebDavOnly && filterType != FilterType.YandexOnly && filterType != FilterType.kDriveOnly)
{
return folders;
}
var providerKey = filterType switch
{
FilterType.YandexOnly => ProviderTypes.Yandex.ToStringFast(),
FilterType.WebDavOnly => ProviderTypes.WebDav.ToStringFast(),
FilterType.kDriveOnly => ProviderTypes.kDrive.ToStringFast(),
_ => throw new NotImplementedException(),
};
return folders.Where(x => providerKey == x.ProviderKey);
}
}

View File

@ -455,4 +455,10 @@ internal class SharePointFolderDao : SharePointDaoBase, IFolderDao<string>
{
return Task.FromResult(2L * 1024L * 1024L * 1024L);
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.BoxOnly or FilterType.DropboxV2Only or FilterType.kDriveOnly or FilterType.GoogleDriveOnly
or FilterType.YandexOnly or FilterType.WebDavOnly or FilterType.OneDriveOnly;
}
}

View File

@ -521,4 +521,10 @@ internal class SharpBoxFolderDao : SharpBoxDaoBase, IFolderDao<string>
return Task.FromResult(chunkedUpload ? storageMaxUploadSize : Math.Min(storageMaxUploadSize, _setupInfo.AvailableFileSize));
}
public override bool CheckInvalidFilter(FilterType filterType)
{
return base.CheckInvalidFilter(filterType) || filterType is FilterType.BoxOnly or FilterType.DropboxV2Only or FilterType.SharePointOnly
or FilterType.GoogleDriveOnly or FilterType.OneDriveOnly;
}
}

View File

@ -670,6 +670,14 @@ public class VirtualRoomsCommonController : ApiControllerBase
RoomFilterType.ReviewRoomOnly => FilterType.ReviewRooms,
RoomFilterType.CustomRoomOnly => FilterType.CustomRooms,
RoomFilterType.FoldersOnly => FilterType.FoldersOnly,
RoomFilterType.GoogleDriveOnly => FilterType.GoogleDriveOnly,
RoomFilterType.BoxOnly => FilterType.BoxOnly,
RoomFilterType.DropboxV2Only => FilterType.DropboxV2Only,
RoomFilterType.OneDriveOnly => FilterType.OneDriveOnly,
RoomFilterType.SharePointOnly => FilterType.SharePointOnly,
RoomFilterType.YandexOnly => FilterType.YandexOnly,
RoomFilterType.kDriveOnly => FilterType.kDriveOnly,
RoomFilterType.WebDavOnly => FilterType.WebDavOnly,
_ => FilterType.None
};