Merge branch 'master' into feature/files

This commit is contained in:
Nikita Gopienko 2020-09-08 15:20:05 +03:00
commit d30026b82f
9 changed files with 280 additions and 230 deletions

View File

@ -283,7 +283,7 @@ namespace ASC.Notify.Engine
{
if (request.Recipient is IDirectRecipient)
{
var subscriptionSource = request.NotifySource.GetSubscriptionProvider();
var subscriptionSource = request.GetSubscriptionProvider(serviceScope);
if (!request.IsNeedCheckSubscriptions || !subscriptionSource.IsUnsubscribe(request.Recipient as IDirectRecipient, request.NotifyAction, request.ObjectID))
{
var directresponses = new List<SendResponse>(1);
@ -309,7 +309,7 @@ namespace ASC.Notify.Engine
}
else
{
var recipientProvider = request.NotifySource.GetRecipientsProvider();
var recipientProvider = request.GetRecipientsProvider(serviceScope);
try
{
@ -358,9 +358,9 @@ namespace ASC.Notify.Engine
try
{
PrepareRequestFillSenders(request);
PrepareRequestFillPatterns(request);
PrepareRequestFillTags(request);
PrepareRequestFillSenders(request, serviceScope);
PrepareRequestFillPatterns(request, serviceScope);
PrepareRequestFillTags(request, serviceScope);
}
catch (Exception ex)
{
@ -421,7 +421,7 @@ namespace ASC.Notify.Engine
{
if (request == null) throw new ArgumentNullException("request");
var recipientProvider = request.NotifySource.GetRecipientsProvider();
var recipientProvider = request.GetRecipientsProvider(serviceScope);
var recipient = request.Recipient as IDirectRecipient;
var addresses = recipient.Addresses;
@ -450,7 +450,7 @@ namespace ASC.Notify.Engine
noticeMessage.Pattern = pattern;
noticeMessage.ContentType = pattern.ContentType;
noticeMessage.AddArgument(request.Arguments.ToArray());
var patternProvider = request.NotifySource.GetPatternProvider();
var patternProvider = request.GetPatternProvider(serviceScope);
var formatter = patternProvider.GetFormatter(pattern);
try
@ -500,11 +500,11 @@ namespace ASC.Notify.Engine
}
}
private void PrepareRequestFillSenders(NotifyRequest request)
private void PrepareRequestFillSenders(NotifyRequest request, IServiceScope serviceScope)
{
if (request.SenderNames == null)
{
var subscriptionProvider = request.NotifySource.GetSubscriptionProvider();
var subscriptionProvider = request.GetSubscriptionProvider(serviceScope);
var senderNames = new List<string>();
senderNames.AddRange(subscriptionProvider.GetSubscriptionMethod(request.NotifyAction, request.Recipient) ?? new string[0]);
@ -514,14 +514,14 @@ namespace ASC.Notify.Engine
}
}
private void PrepareRequestFillPatterns(NotifyRequest request)
private void PrepareRequestFillPatterns(NotifyRequest request, IServiceScope serviceScope)
{
if (request.Patterns == null)
{
request.Patterns = new IPattern[request.SenderNames.Length];
if (request.Patterns.Length == 0) return;
var apProvider = request.NotifySource.GetPatternProvider();
var apProvider = request.GetPatternProvider(serviceScope);
for (var i = 0; i < request.SenderNames.Length; i++)
{
var senderName = request.SenderNames[i];
@ -540,9 +540,9 @@ namespace ASC.Notify.Engine
}
}
private void PrepareRequestFillTags(NotifyRequest request)
private void PrepareRequestFillTags(NotifyRequest request, IServiceScope serviceScope)
{
var patternProvider = request.NotifySource.GetPatternProvider();
var patternProvider = request.GetPatternProvider(serviceScope);
foreach (var pattern in request.Patterns)
{
IPatternFormatter formatter;

View File

@ -41,7 +41,7 @@ namespace ASC.Notify.Engine
{
public class NotifyRequest
{
public INotifySource NotifySource { get; internal set; }
private INotifySource NotifySource { get; set; }
public INotifyAction NotifyAction { get; internal set; }
@ -143,5 +143,25 @@ namespace ASC.Notify.Engine
{
return new NoticeMessage(recipient, NotifyAction, ObjectID);
}
public IActionProvider GetActionProvider(IServiceScope scope)
{
return ((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetActionProvider();
}
public IPatternProvider GetPatternProvider(IServiceScope scope)
{
return ((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetPatternProvider();
}
public IRecipientProvider GetRecipientsProvider(IServiceScope scope)
{
return ((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetRecipientsProvider();
}
public ISubscriptionProvider GetSubscriptionProvider(IServiceScope scope)
{
return ((INotifySource)scope.ServiceProvider.GetService(NotifySource.GetType())).GetSubscriptionProvider();
}
}
}

View File

@ -70,6 +70,29 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Update="Services\NotifyService\FilesPatternResource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>FilesPatternResource.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Services\NotifyService\FilesPatternResource.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>FilesPatternResource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Remove="Services\NotifyService\patterns.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Services\NotifyService\patterns.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\FilesCommonResource.de.resx">
<DependentUpon>FilesCommonResource.resx</DependentUpon>

View File

@ -36,6 +36,7 @@ using ASC.Web.Core;
using ASC.Web.Core.PublicResources;
using ASC.Web.Files.Classes;
using ASC.Web.Files.Core.Search;
using ASC.Web.Studio.Core.Notify;
namespace ASC.Web.Files.Configuration
{
@ -60,7 +61,8 @@ namespace ASC.Web.Files.Configuration
// FilesSpaceUsageStatManager filesSpaceUsageStatManager,
CoreBaseSettings coreBaseSettings,
AuthContext authContext,
UserManager userManager
UserManager userManager,
IServiceProvider serviceProvider
// SubscriptionManager subscriptionManager
)
{
@ -68,6 +70,7 @@ namespace ASC.Web.Files.Configuration
CoreBaseSettings = coreBaseSettings;
AuthContext = authContext;
UserManager = userManager;
ServiceProvider = serviceProvider;
//SubscriptionManager = subscriptionManager;
}
@ -101,6 +104,8 @@ namespace ASC.Web.Files.Configuration
CanNotBeDisabled = true,
};
NotifyConfiguration.Configure(ServiceProvider);
//SearchHandlerManager.Registry(new SearchHandler());
}
@ -175,6 +180,7 @@ namespace ASC.Web.Files.Configuration
{
if (services.TryAddScoped<ProductEntryPoint>())
{
services.TryAddScoped<IWebItem, ProductEntryPoint>();
return services
.AddFilesSpaceUsageStatManagerService()
.AddCoreBaseSettingsService()

View File

@ -19,7 +19,7 @@ namespace ASC.Web.Files.Services.NotifyService {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class FilesPatternResource {
@ -39,7 +39,7 @@ namespace ASC.Web.Files.Services.NotifyService {
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASC.Web.Files.Services.NotifyService.FilesPatternResource", typeof(FilesPatternResource).Assembly);
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASC.Files.Core.Services.NotifyService.FilesPatternResource", typeof(FilesPatternResource).Assembly);
resourceMan = temp;
}
return resourceMan;
@ -144,13 +144,13 @@ namespace ASC.Web.Files.Services.NotifyService {
/// <summary>
/// Looks up a localized string similar to &lt;patterns&gt;
/// &lt;formatter type=&quot;ASC.Notify.Patterns.NVelocityPatternFormatter, ASC.Common&quot; /&gt;
/// &lt;formatter type=&quot;ASC.Notify.Patterns.NVelocityPatternFormatter, ASC.Core.Common&quot; /&gt;
///
/// &lt;pattern id=&quot;DocuSignComplete&quot; sender=&quot;email.sender&quot;&gt;
/// &lt;subject resource=&quot;|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files&quot; /&gt;
/// &lt;body styler=&quot;ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile&quot; resource=&quot;|pattern_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files&quot; /&gt;
/// &lt;subject resource=&quot;|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core&quot; /&gt;
/// &lt;body styler=&quot;ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile&quot; resource=&quot;|pattern_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core&quot; /&gt;
/// &lt;/pattern&gt;
/// &lt;pattern id=&quot;DocuSignComplete&quot; se [rest of string was truncated]&quot;;.
/// &lt;pattern id=&quot;DocuSignComplete&quot; send [rest of string was truncated]&quot;;.
/// </summary>
public static string patterns {
get {

View File

@ -1,30 +1,30 @@
<patterns>
<formatter type="ASC.Notify.Patterns.NVelocityPatternFormatter, ASC.Common" />
<formatter type="ASC.Notify.Patterns.NVelocityPatternFormatter, ASC.Core.Common" />
<pattern id="DocuSignComplete" sender="email.sender">
<subject resource="|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="DocuSignComplete" sender="messanger.sender">
<subject resource="|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_DocuSignComplete|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$DocumentURL</body>
</pattern>
<pattern id="DocuSignStatus" sender="email.sender">
<subject resource="|subject_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="DocuSignStatus" sender="messanger.sender">
<subject resource="|subject_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_DocuSignStatus|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$Message: $DocumentTitle</body>
</pattern>
<pattern id="MailMergeEnd" sender="email.sender">
<subject resource="|subject_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="MailMergeEnd" sender="messanger.sender">
<subject resource="|subject_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_MailMergeEnd|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$__AuthorName
$Message
@ -32,11 +32,11 @@ $Message
</pattern>
<pattern id="ShareDocument" sender="email.sender">
<subject resource="|subject_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="ShareDocument" sender="messanger.sender">
<subject resource="|subject_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_ShareDocument|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$__AuthorName
$AccessRights
@ -48,11 +48,11 @@ $DocumentURL
</pattern>
<pattern id="ShareFolder" sender="email.sender">
<subject resource="|subject_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="ShareFolder" sender="messanger.sender">
<subject resource="|subject_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_ShareFolder|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$__AuthorName
$AccessRights
@ -64,11 +64,11 @@ $__VirtualRootPath/products/files/#$FolderID
</pattern>
<pattern id="EditorMentions" sender="email.sender">
<subject resource="|subject_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
</pattern>
<pattern id="EditorMentions" sender="messanger.sender">
<subject resource="|subject_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Web.Files" />
<subject resource="|subject_EditorMentions|ASC.Web.Files.Services.NotifyService.FilesPatternResource,ASC.Files.Core" />
<body styler="ASC.Notify.Textile.JabberStyler, ASC.Notify.Textile">$__AuthorName
$DocumentTitle

View File

@ -7,6 +7,7 @@ using ASC.Api.Documents;
using ASC.Common;
using ASC.Web.Files;
using ASC.Web.Files.HttpHandlers;
using ASC.Web.Studio.Core.Notify;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@ -42,7 +43,8 @@ namespace ASC.Files
.AddFileHandlerService()
.AddChunkedUploaderHandlerService()
.AddThirdPartyAppHandlerService()
.AddDocuSignHandlerService();
.AddDocuSignHandlerService()
.AddNotifyConfiguration();
base.ConfigureServices(services);
}

View File

@ -242,14 +242,14 @@ namespace ASC.Web.Studio.Core.Notify
}
private static void BeforeTransferRequest(NotifyEngine sender, NotifyRequest request, IServiceScope serviceScope)
private static void BeforeTransferRequest(NotifyEngine sender, NotifyRequest request, IServiceScope scope)
{
var aid = Guid.Empty;
var aname = string.Empty;
var tenant = serviceScope.ServiceProvider.GetService<TenantManager>().GetCurrentTenant();
var authContext = serviceScope.ServiceProvider.GetService<AuthContext>();
var userManager = serviceScope.ServiceProvider.GetService<UserManager>();
var displayUserSettingsHelper = serviceScope.ServiceProvider.GetService<DisplayUserSettingsHelper>();
var tenant = scope.ServiceProvider.GetService<TenantManager>().GetCurrentTenant();
var authContext = scope.ServiceProvider.GetService<AuthContext>();
var userManager = scope.ServiceProvider.GetService<UserManager>();
var displayUserSettingsHelper = scope.ServiceProvider.GetService<DisplayUserSettingsHelper>();
if (authContext.IsAuthenticated)
{
@ -262,9 +262,7 @@ namespace ASC.Web.Studio.Core.Notify
.Replace("<", "&#60");
}
}
using var scope = ServiceProvider.CreateScope();
var tenantExtra = scope.ServiceProvider.GetService<TenantExtra>();
var webItemManagerSecurity = scope.ServiceProvider.GetService<WebItemManagerSecurity>();
var webItemManager = scope.ServiceProvider.GetService<WebItemManager>();
var configuration = scope.ServiceProvider.GetService<IConfiguration>();
var tenantLogoManager = scope.ServiceProvider.GetService<TenantLogoManager>();
@ -390,7 +388,8 @@ namespace ASC.Web.Studio.Core.Notify
.AddCoreBaseSettingsService()
.AddAdditionalWhiteLabelSettingsService()
.AddCommonLinkUtilityService()
.AddMailWhiteLabelSettingsService();
.AddMailWhiteLabelSettingsService()
.AddStudioNotifyHelperService();
}
}
}