removed .result
This commit is contained in:
parent
6c78438b75
commit
bd62a2a4fd
@ -706,7 +706,7 @@ public class TariffService : ITariffService
|
||||
|
||||
var tariffRows = coreDbContext.TariffRows
|
||||
.Where(row => row.TariffId == r.Id && row.Tenant == tenant);
|
||||
|
||||
|
||||
tariff.Quotas = await tariffRows.Select(r => new Quota(r.Quota, r.Quantity)).ToListAsync();
|
||||
|
||||
return tariff;
|
||||
@ -783,7 +783,7 @@ public class TariffService : ITariffService
|
||||
|
||||
if (inserted)
|
||||
{
|
||||
var t = await _tenantService.GetTenantAsync(tenant);
|
||||
var t = await _tenantService.GetTenantAsync(tenant);
|
||||
if (t != null)
|
||||
{
|
||||
// update tenant.LastModified to flush cache in documents
|
||||
@ -830,7 +830,7 @@ public class TariffService : ITariffService
|
||||
|
||||
if (_trialEnabled)
|
||||
{
|
||||
var trial = tariff.Quotas.Exists(q => _quotaService.GetTenantQuotaAsync(q.Id).Result.Trial);
|
||||
var trial = await tariff.Quotas.ToAsyncEnumerable().AnyAwaitAsync(async q => (await _quotaService.GetTenantQuotaAsync(q.Id)).Trial);
|
||||
if (trial)
|
||||
{
|
||||
setDelay = false;
|
||||
|
@ -228,7 +228,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
{
|
||||
var sendResponces = new List<SendResponse>();
|
||||
|
||||
var response = CheckPreventInterceptors(request, InterceptorPlace.Prepare, serviceScope, null);
|
||||
var response = await CheckPreventInterceptors(request, InterceptorPlace.Prepare, serviceScope, null);
|
||||
if (response != null)
|
||||
{
|
||||
sendResponces.Add(response);
|
||||
@ -252,9 +252,9 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
return result;
|
||||
}
|
||||
|
||||
private SendResponse CheckPreventInterceptors(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope, string sender)
|
||||
private async Task<SendResponse> CheckPreventInterceptors(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope, string sender)
|
||||
{
|
||||
return request.Intercept(place, serviceScope) ? new SendResponse(request.NotifyAction, sender, request.Recipient, SendResult.Prevented) : null;
|
||||
return await request.Intercept(place, serviceScope) ? new SendResponse(request.NotifyAction, sender, request.Recipient, SendResult.Prevented) : null;
|
||||
}
|
||||
|
||||
private async Task<List<SendResponse>> SendGroupNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
@ -290,7 +290,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
{
|
||||
if (request.Recipient is IRecipientsGroup)
|
||||
{
|
||||
var checkresp = CheckPreventInterceptors(request, InterceptorPlace.GroupSend, serviceScope, null);
|
||||
var checkresp = await CheckPreventInterceptors(request, InterceptorPlace.GroupSend, serviceScope, null);
|
||||
if (checkresp != null)
|
||||
{
|
||||
responces.Add(checkresp);
|
||||
@ -341,7 +341,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
|
||||
var responses = new List<SendResponse>();
|
||||
var response = CheckPreventInterceptors(request, InterceptorPlace.DirectSend, serviceScope, null);
|
||||
var response = await CheckPreventInterceptors(request, InterceptorPlace.DirectSend, serviceScope, null);
|
||||
if (response != null)
|
||||
{
|
||||
responses.Add(response);
|
||||
@ -411,7 +411,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
|
||||
request.CurrentMessage = noticeMessage;
|
||||
var preventresponse = CheckPreventInterceptors(request, InterceptorPlace.MessageSend, serviceScope, channel.SenderName);
|
||||
var preventresponse = await CheckPreventInterceptors(request, InterceptorPlace.MessageSend, serviceScope, channel.SenderName);
|
||||
if (preventresponse != null)
|
||||
{
|
||||
return preventresponse;
|
||||
|
@ -60,7 +60,7 @@ public class NotifyRequest
|
||||
_log = options.CreateLogger("ASC.Notify");
|
||||
}
|
||||
|
||||
internal bool Intercept(InterceptorPlace place, IServiceScope serviceScope)
|
||||
internal async Task<bool> Intercept(InterceptorPlace place, IServiceScope serviceScope)
|
||||
{
|
||||
var result = false;
|
||||
foreach (var interceptor in _interceptors)
|
||||
@ -69,7 +69,7 @@ public class NotifyRequest
|
||||
{
|
||||
try
|
||||
{
|
||||
if (interceptor.PreventSend(this, place, serviceScope))
|
||||
if (await interceptor.PreventSend(this, place, serviceScope))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
@ -28,28 +28,44 @@ namespace ASC.Notify.Engine;
|
||||
|
||||
public class SendInterceptorSkeleton : ISendInterceptor
|
||||
{
|
||||
private readonly Func<NotifyRequest, InterceptorPlace, IServiceScope, bool> _method;
|
||||
private readonly Func<NotifyRequest, InterceptorPlace, IServiceScope, bool> _method;
|
||||
private readonly Func<NotifyRequest, InterceptorPlace, IServiceScope, Task<bool>> _methodAsync;
|
||||
public string Name { get; internal set; }
|
||||
public InterceptorPlace PreventPlace { get; internal set; }
|
||||
public InterceptorLifetime Lifetime { get; internal set; }
|
||||
|
||||
public SendInterceptorSkeleton(string name, InterceptorPlace preventPlace, InterceptorLifetime lifetime, Func<NotifyRequest, InterceptorPlace, IServiceScope, bool> sendInterceptor)
|
||||
private SendInterceptorSkeleton(string name, InterceptorPlace preventPlace, InterceptorLifetime lifetime)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentException("Empty name.", nameof(name));
|
||||
}
|
||||
|
||||
ArgumentNullException.ThrowIfNull(sendInterceptor);
|
||||
|
||||
_method = sendInterceptor;
|
||||
Name = name;
|
||||
PreventPlace = preventPlace;
|
||||
Lifetime = lifetime;
|
||||
}
|
||||
|
||||
public SendInterceptorSkeleton(string name, InterceptorPlace preventPlace, InterceptorLifetime lifetime, Func<NotifyRequest, InterceptorPlace, IServiceScope, bool> sendInterceptor)
|
||||
: this(name, preventPlace, lifetime)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(sendInterceptor);
|
||||
|
||||
_method = sendInterceptor;
|
||||
}
|
||||
|
||||
public SendInterceptorSkeleton(string name, InterceptorPlace preventPlace, InterceptorLifetime lifetime, Func<NotifyRequest, InterceptorPlace, IServiceScope, Task<bool>> sendInterceptor)
|
||||
: this(name, preventPlace, lifetime)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(sendInterceptor);
|
||||
|
||||
_methodAsync = sendInterceptor;
|
||||
}
|
||||
|
||||
public bool PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope)
|
||||
public async Task<bool> PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope)
|
||||
{
|
||||
return _method(request, place, serviceScope);
|
||||
if (_method != null) return _method(request, place, serviceScope);
|
||||
|
||||
return await _methodAsync(request, place, serviceScope);
|
||||
}
|
||||
}
|
||||
|
@ -46,16 +46,16 @@ class SingleRecipientInterceptor : ISendInterceptor
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public bool PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope)
|
||||
public Task<bool> PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope)
|
||||
{
|
||||
var sendTo = request.Recipient;
|
||||
if (!_sendedTo.Exists(rec => Equals(rec, sendTo)))
|
||||
{
|
||||
_sendedTo.Add(sendTo);
|
||||
|
||||
return false;
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ public interface ISendInterceptor
|
||||
string Name { get; }
|
||||
InterceptorPlace PreventPlace { get; }
|
||||
InterceptorLifetime Lifetime { get; }
|
||||
bool PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope);
|
||||
Task<bool> PreventSend(NotifyRequest request, InterceptorPlace place, IServiceScope serviceScope);
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public class PortalController : ControllerBase
|
||||
_log.LogDebug("PortalName = {0}; Elapsed ms. CacheController.AddTenantToCache: {1}", model.PortalName, sw.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
t = await _hostedSolution.RegisterTenantAsync(info);
|
||||
t = await _hostedSolution.RegisterTenantAsync(info);
|
||||
|
||||
/*********/
|
||||
|
||||
|
@ -87,11 +87,6 @@ internal class OneDriveStorage : IThirdPartyStorage<Item, Item, Item>
|
||||
IsOpened = false;
|
||||
}
|
||||
|
||||
public bool CheckAccess()
|
||||
{
|
||||
return CheckAccessAsync().Result;
|
||||
}
|
||||
|
||||
public async Task<bool> CheckAccessAsync()
|
||||
{
|
||||
var request = await OnedriveClient
|
||||
|
@ -95,7 +95,7 @@ public class FilesModule : FeedModule
|
||||
targetCond = true;
|
||||
}
|
||||
|
||||
return targetCond && _fileSecurity.CanReadAsync(file, userId).Result;
|
||||
return targetCond && await _fileSecurity.CanReadAsync(file, userId);
|
||||
}
|
||||
|
||||
public override async Task VisibleForAsync(List<Tuple<FeedRow, object>> feed, Guid userId)
|
||||
|
@ -92,7 +92,7 @@ public class FoldersModule : FeedModule
|
||||
targetCond = true;
|
||||
}
|
||||
|
||||
return targetCond && _fileSecurity.CanReadAsync(folder, userId).Result;
|
||||
return targetCond && await _fileSecurity.CanReadAsync(folder, userId);
|
||||
}
|
||||
|
||||
public override async Task<IEnumerable<int>> GetTenantsWithFeeds(DateTime fromTime)
|
||||
|
@ -92,7 +92,7 @@ public class RoomsModule : FeedModule
|
||||
targetCond = true;
|
||||
}
|
||||
|
||||
return targetCond && _fileSecurity.CanReadAsync(folder, userId).Result;
|
||||
return targetCond && await _fileSecurity.CanReadAsync(folder, userId);
|
||||
}
|
||||
|
||||
public override async Task<IEnumerable<Tuple<Feed.Aggregator.Feed, object>>> GetFeeds(FeedFilter filter)
|
||||
@ -115,7 +115,7 @@ public class RoomsModule : FeedModule
|
||||
if (shareRecord == null)
|
||||
{
|
||||
var roomCreatedUtc = _tenantUtil.DateTimeToUtc(room.CreateOn);
|
||||
|
||||
|
||||
return new Feed.Aggregator.Feed(room.CreateBy, roomCreatedUtc)
|
||||
{
|
||||
Item = RoomItem,
|
||||
|
@ -98,7 +98,7 @@ public class RadicaleController : BaseSettingsController
|
||||
}
|
||||
else if (getResponse.StatusCode == 404)
|
||||
{
|
||||
var createResponse = _cardDavAddressbook.Create("", "", "", sharedCardUrl, rootAuthorization).Result;
|
||||
var createResponse = await _cardDavAddressbook.Create("", "", "", sharedCardUrl, rootAuthorization);
|
||||
if (createResponse.Completed)
|
||||
{
|
||||
try
|
||||
|
@ -1,72 +0,0 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// 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.Web.Core;
|
||||
|
||||
public static class ProductModuleExtension
|
||||
{
|
||||
|
||||
|
||||
public static string GetSmallIconAbsoluteURL(this IModule module, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (module == null || module.Context == null || string.IsNullOrEmpty(module.Context.SmallIconFileName))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(module.Context.SmallIconFileName, module.ID);
|
||||
}
|
||||
|
||||
public static string GetSmallIconAbsoluteURL(this IProduct product, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (product == null || product.Context == null || string.IsNullOrEmpty(product.Context.SmallIconFileName))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(product.Context.SmallIconFileName, product.ID);
|
||||
}
|
||||
|
||||
public static string GetIconAbsoluteURL(this IModule module, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (module == null || module.Context == null || string.IsNullOrEmpty(module.Context.IconFileName))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(module.Context.IconFileName, module.ID);
|
||||
}
|
||||
|
||||
public static string GetIconAbsoluteURL(this IProduct product, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (product == null || product.Context == null || string.IsNullOrEmpty(product.Context.IconFileName))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(product.Context.IconFileName, product.ID);
|
||||
}
|
||||
}
|
@ -63,66 +63,6 @@ public static class WebItemExtension
|
||||
return sysname;
|
||||
}
|
||||
|
||||
public static string GetDisabledIconAbsoluteURL(this IWebItem item, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (item == null || item.Context == null || string.IsNullOrEmpty(item.Context.DisabledIconFileName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(item.Context.DisabledIconFileName, item.ID);
|
||||
}
|
||||
|
||||
public static string GetSmallIconAbsoluteURL(this IWebItem item, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (item == null || item.Context == null || string.IsNullOrEmpty(item.Context.SmallIconFileName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(item.Context.SmallIconFileName, item.ID);
|
||||
}
|
||||
|
||||
public static string GetIconAbsoluteURL(this IWebItem item, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (item == null || item.Context == null || string.IsNullOrEmpty(item.Context.IconFileName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(item.Context.IconFileName, item.ID);
|
||||
}
|
||||
|
||||
public static string GetLargeIconAbsoluteURL(this IWebItem item, WebImageSupplier webImageSupplier)
|
||||
{
|
||||
if (item == null || item.Context == null || string.IsNullOrEmpty(item.Context.LargeIconFileName))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return webImageSupplier.GetAbsoluteWebPath(item.Context.LargeIconFileName, item.ID);
|
||||
}
|
||||
|
||||
public static List<string> GetUserOpportunities(this IWebItem item)
|
||||
{
|
||||
return item.Context.UserOpportunities != null ? item.Context.UserOpportunities() : new List<string>();
|
||||
}
|
||||
|
||||
public static List<string> GetAdminOpportunities(this IWebItem item)
|
||||
{
|
||||
return item.Context.AdminOpportunities != null ? item.Context.AdminOpportunities() : new List<string>();
|
||||
}
|
||||
|
||||
public static bool HasComplexHierarchyOfAccessRights(this IWebItem item)
|
||||
{
|
||||
return item.Context.HasComplexHierarchyOfAccessRights;
|
||||
}
|
||||
|
||||
public static bool CanNotBeDisabled(this IWebItem item)
|
||||
{
|
||||
return item.Context.CanNotBeDisabled;
|
||||
}
|
||||
|
||||
|
||||
public static async Task<bool> IsDisabledAsync(this IWebItem item, WebItemSecurity webItemSecurity, AuthContext authContext)
|
||||
{
|
||||
|
@ -106,10 +106,10 @@ public class NotifyConfiguration
|
||||
"ProductSecurityInterceptor",
|
||||
InterceptorPlace.DirectSend,
|
||||
InterceptorLifetime.Global,
|
||||
(r, p, scope) =>
|
||||
async (r, p, scope) =>
|
||||
{
|
||||
var scopeClass = scope.ServiceProvider.GetRequiredService<ProductSecurityInterceptor>();
|
||||
return scopeClass.InterceptAsync(r, p).Result;
|
||||
return await scopeClass.InterceptAsync(r, p);
|
||||
});
|
||||
client.AddInterceptor(securityAndCulture);
|
||||
|
||||
@ -369,19 +369,19 @@ public class NotifyTransferRequest : INotifyEngineAction
|
||||
private async Task AddLetterLogoAsync(NotifyRequest request)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var attachment = await _tenantLogoManager.GetMailLogoAsAttacmentAsync();
|
||||
try
|
||||
{
|
||||
var attachment = await _tenantLogoManager.GetMailLogoAsAttacmentAsync();
|
||||
|
||||
if (attachment != null)
|
||||
{
|
||||
request.Arguments.Add(new TagValue(CommonTags.LetterLogo, "cid:" + attachment.ContentId));
|
||||
request.Arguments.Add(new TagValue(CommonTags.EmbeddedAttachments, new[] { attachment }));
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
if (attachment != null)
|
||||
{
|
||||
_log.ErrorAddLetterLogo(error);
|
||||
request.Arguments.Add(new TagValue(CommonTags.LetterLogo, "cid:" + attachment.ContentId));
|
||||
request.Arguments.Add(new TagValue(CommonTags.EmbeddedAttachments, new[] { attachment }));
|
||||
}
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
_log.ErrorAddLetterLogo(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,21 +56,6 @@ public class WebImageSupplier
|
||||
return GetImageAbsoluteWebPath(imgFileName, moduleID);
|
||||
}
|
||||
|
||||
public string GetImageFolderAbsoluteWebPath()
|
||||
{
|
||||
return GetImageFolderAbsoluteWebPath(Guid.Empty);
|
||||
}
|
||||
|
||||
public string GetImageFolderAbsoluteWebPath(Guid moduleID)
|
||||
{
|
||||
if (_httpContextAccessor?.HttpContext == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var currentThemePath = GetPartImageFolderRel(moduleID);
|
||||
return _webPath.GetPathAsync(currentThemePath).Result;
|
||||
}
|
||||
|
||||
private string GetImageAbsoluteWebPath(string fileName, Guid partID)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user