Skip to content

Commit

Permalink
Merge branch 'develop' of git.onlyoffice.com:ONLYOFFICE/DocSpace-serv…
Browse files Browse the repository at this point in the history
…er into develop
  • Loading branch information
andreysavihin committed Dec 16, 2024
2 parents e6e9974 + 7481fc3 commit efe912e
Show file tree
Hide file tree
Showing 24 changed files with 439 additions and 208 deletions.
2 changes: 1 addition & 1 deletion common/ASC.ActiveDirectory/Base/Settings/LdapSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ public string LocationAttribute
/// <type>System.String, System</type>
public string AcceptCertificateHash { get; set; }

/// <summary>Users type (All, RoomAdmin, User, DocSpaceAdmin, Collaborator)</summary>
/// <summary>Users type (All, RoomAdmin, Guest, DocSpaceAdmin, User)</summary>
/// <type>ASC.Core.Users.EmployeeType, ASC.Core.Common</type>
public EmployeeType UsersType { get; set; }

Expand Down
18 changes: 15 additions & 3 deletions common/ASC.Core.Common/Billing/TariffService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,25 @@ public async Task<Tariff> GetTariffAsync(int tenantId, bool withRequestToPayment

await UpdateCacheAsync(tariff.Id);
}
catch (Exception error)
catch (BillingNotFoundException billingNotFoundException)
{
if (error is not BillingNotFoundException)
if (tariff.Id != 0 && tariff.State == TariffState.Paid)
{
LogError(error, tenantId.ToString());
LogError(billingNotFoundException, tenantId.ToString());

tariff.DueDate = DateTime.Today.AddDays(-1);

if (await SaveBillingInfoAsync(tenantId, tariff))
{
tariff = await CalculateTariffAsync(tenantId, tariff);
await UpdateCacheAsync(tariff.Id);
}
}
}
catch (Exception error)
{
LogError(error, tenantId.ToString());
}

if (tariff.Id == 0)
{
Expand Down
15 changes: 14 additions & 1 deletion common/services/ASC.ElasticSearch/Core/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,15 @@ public Selector<T> MatchAll(string value)

return this;
}


public Selector<T> Nested(Expression<Func<T, object>> fieldSelector, Func<QueryContainerDescriptor<T>, QueryContainer> selector)
{
var path = IsNested(fieldSelector);
_queryContainer &= _queryContainerDescriptor.Nested(a => a.Query(selector).Path(char.ToLower(path[0]) + path[1..]));

return this;
}

public Selector<T> Sort(Expression<Func<T, object>> selector, bool asc)
{
_sortContainerDescriptor = _sortContainerDescriptor.Field(selector, asc ? SortOrder.Ascending : SortOrder.Descending);
Expand Down Expand Up @@ -367,6 +375,11 @@ private string IsNested(Field selector)
return null;
}

if (lambdaExpression.Body is MemberExpression memberExpression && memberExpression.Member.GetCustomAttributes(false).OfType<NestedAttribute>().Any())
{
return memberExpression.Member.Name;
}

if (lambdaExpression.Body is MethodCallExpression { Arguments.Count: > 1 } methodCallExpression)
{
return methodCallExpression.Arguments[0] is not MemberExpression pathMember
Expand Down
12 changes: 6 additions & 6 deletions common/services/ASC.ElasticSearch/Engine/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public OpenSearchClient Instance
{
connectionSettings.DisableDirectStreaming().PrettyJson().EnableDebugMode(r =>
{
// _logger.Debug(r.DebugInformation);
//
// if (r.RequestBodyInBytes != null)
// {
// _logger.Debug($"Request: {Encoding.UTF8.GetString(r.RequestBodyInBytes)}");
// }
logger.Debug(r.DebugInformation);

if (r.RequestBodyInBytes != null)
{
logger.Debug($"Request: {Encoding.UTF8.GetString(r.RequestBodyInBytes)}");
}

if (r.HttpStatusCode is 403 or 500 && r.ResponseBodyInBytes != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ public class GetFolderRequestDto<T>
/// </summary>
[FromQuery(Name = "searchArea")]
public SearchArea SearchArea { get; set; }


[FromQuery(Name = "formsItemKey")]
public string FormsItemKey { get; set; }

[FromQuery(Name = "formsItemType")]
public string FormsItemType{ get; set; }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class RoomContentRequestDto
public bool? WithSubfolders { get; set; }

/// <summary>
/// Room search area (Active, Archive, Any)
/// Room search area (Active, Archive, Any, Recent by links)
/// </summary>
[FromQuery(Name = "searchArea")]
public SearchArea? SearchArea { get; set; }
Expand All @@ -77,25 +77,25 @@ public class RoomContentRequestDto
public bool? ExcludeSubject { get; set; }

/// <summary>
/// Filter by provider name (None, Box, DropBox, GoogleDrive, kDrive, OneDrive, WebDav)
/// Filter by provider name (None, Box, DropBox, GoogleDrive, kDrive, OneDrive, SharePoint, WebDav, Yandex, Storage)
/// </summary>
[FromQuery(Name = "provider")]
public ProviderFilter? Provider { get; set; }

/// <summary>
/// Filter by subject (Owner - 1, Member - 1)
/// Filter by subject (Owner - 0, Member - 1)
/// </summary>
[FromQuery(Name = "subjectFilter")]
public SubjectFilter? SubjectFilter { get; set; }

/// <summary>
/// Filter by quota (Default - 1, Custom - 2)
/// Filter by quota (All - 0, Default - 1, Custom - 2)
/// </summary>
[FromQuery(Name = "quotaFilter")]
public QuotaFilter? QuotaFilter { get; set; }

/// <summary>
/// Filter by storage (Internal - 1, ThirdParty - 2)
/// Filter by storage (None - 0, Internal - 1, ThirdParty - 2)
/// </summary>
[FromQuery(Name = "storageFilter")]
public StorageFilter? StorageFilter { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public class FolderContentDtoHelper(
AuthContext authContext,
BreadCrumbsManager breadCrumbsManager)
{
public async Task<FolderContentDto<T>> GetAsync<T>(T folderId, Guid? userIdOrGroupId, FilterType? filterType, T roomId, bool? searchInContent, bool? withSubFolders, bool? excludeSubject, ApplyFilterOption? applyFilterOption, SearchArea? searchArea, string[] extension = null)
public async Task<FolderContentDto<T>> GetAsync<T>(T folderId, Guid? userIdOrGroupId, FilterType? filterType, T roomId, bool? searchInContent, bool? withSubFolders, bool? excludeSubject, ApplyFilterOption? applyFilterOption, SearchArea? searchArea, string[] extension = null, FormsItemDto formsItemDto = null)
{
var types = filterType.HasValue ? new[] { filterType.Value } : null;
var folderContentWrapper = await ToFolderContentWrapperAsync(folderId, userIdOrGroupId ?? Guid.Empty, types, roomId, searchInContent ?? false, withSubFolders ?? false, excludeSubject ?? false, applyFilterOption ?? ApplyFilterOption.All, extension, searchArea ?? SearchArea.Active);

var folderContentWrapper = await ToFolderContentWrapperAsync(folderId, userIdOrGroupId ?? Guid.Empty, types, roomId, searchInContent ?? false, withSubFolders ?? false, excludeSubject ?? false, applyFilterOption ?? ApplyFilterOption.All, extension, searchArea ?? SearchArea.Active, formsItemDto);

return folderContentWrapper.NotFoundIfNull();
}
Expand Down Expand Up @@ -221,7 +221,7 @@ await fileSecurityCommon.IsDocSpaceAdministratorAsync(authContext.CurrentAccount
}
}

private async Task<FolderContentDto<T>> ToFolderContentWrapperAsync<T>(T folderId, Guid userIdOrGroupId, IEnumerable<FilterType> filterTypes, T roomId, bool searchInContent, bool withSubFolders, bool excludeSubject, ApplyFilterOption applyFilterOption, string[] extension, SearchArea searchArea)
private async Task<FolderContentDto<T>> ToFolderContentWrapperAsync<T>(T folderId, Guid userIdOrGroupId, IEnumerable<FilterType> filterTypes, T roomId, bool searchInContent, bool withSubFolders, bool excludeSubject, ApplyFilterOption applyFilterOption, string[] extension, SearchArea searchArea, FormsItemDto formsItemDto)
{
OrderBy orderBy = null;
if (SortedByTypeExtensions.TryParse(apiContext.SortBy, true, out var sortBy))
Expand All @@ -231,7 +231,7 @@ private async Task<FolderContentDto<T>> ToFolderContentWrapperAsync<T>(T folderI

var startIndex = Convert.ToInt32(apiContext.StartIndex);
var items = await fileStorageService.GetFolderItemsAsync(folderId, startIndex, Convert.ToInt32(apiContext.Count), filterTypes, filterTypes?.FirstOrDefault() == FilterType.ByUser, userIdOrGroupId.ToString(), apiContext.FilterValue, extension, searchInContent, withSubFolders, orderBy, excludeSubject: excludeSubject,
roomId: roomId, applyFilterOption: applyFilterOption, searchArea: searchArea);
roomId: roomId, applyFilterOption: applyFilterOption, searchArea: searchArea, formsItemDto: formsItemDto);

return await GetAsync(folderId, items, startIndex);
}
Expand Down
29 changes: 29 additions & 0 deletions products/ASC.Files/Core/ApiModels/ResponseDto/FormsItemDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// 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
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// 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

namespace ASC.Files.Core.ApiModels.ResponseDto;

public record FormsItemDto(string Key, string Type);
6 changes: 4 additions & 2 deletions products/ASC.Files/Core/Core/Dao/Interfaces/IFileDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ IAsyncEnumerable<File<T>> GetFilesFilteredAsync(IEnumerable<T> fileIds, FilterTy
/// <param name="withShared"></param>
/// <param name="containingMyFiles"></param>
/// <param name="parentType"></param>
/// <param name="formsItemDto"></param>
/// <returns>list of files</returns>
/// <remarks>
/// Return only the latest versions of files of a folder
/// </remarks>
IAsyncEnumerable<File<T>> GetFilesAsync(T parentId, OrderBy orderBy, FilterType filterType, bool subjectGroup, Guid subjectID, string searchText, string[] extension,
bool searchInContent, bool withSubfolders = false, bool excludeSubject = false, int offset = 0, int count = -1, T roomId = default, bool withShared = false, bool containingMyFiles = false, FolderType parentType = FolderType.DEFAULT);
bool searchInContent, bool withSubfolders = false, bool excludeSubject = false, int offset = 0, int count = -1, T roomId = default, bool withShared = false, bool containingMyFiles = false, FolderType parentType = FolderType.DEFAULT, FormsItemDto formsItemDto = null);

/// <summary>
/// Get stream of file
Expand Down Expand Up @@ -346,7 +347,8 @@ IAsyncEnumerable<File<T>> GetFilesAsync(IEnumerable<T> parentIds, FilterType fil
Task SaveProperties(T fileId, EntryProperties<T> entryProperties);

Task<int> GetFilesCountAsync(T parentId, FilterType filterType, bool subjectGroup, Guid subjectId, string searchText, string[] extension, bool searchInContent,
bool withSubfolders = false, bool excludeSubject = false, T roomId = default);
bool withSubfolders = false, bool excludeSubject = false, T roomId = default,
FormsItemDto formsItemDto = null);

Task<int> SetCustomOrder(T fileId, T parentFolderId, int order);

Expand Down
Loading

0 comments on commit efe912e

Please sign in to comment.