From 96df0ab8ca90733615c9fd12c5e3ace00810e56b Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Mon, 7 Sep 2020 16:53:39 +0300 Subject: [PATCH 1/7] Api: added payment settings --- config/appsettings.json | 4 +++- products/ASC.Files/Core/Helpers/Global.cs | 2 +- .../Services/DocumentService/Configuration.cs | 7 +++--- .../Controllers/SettingsController.cs | 22 +++++++++++++++++++ .../Notify/StudioNotifyService.cs | 2 +- web/ASC.Web.Core/Utility/CommonLinkUtility.cs | 2 +- .../AdditionalWhiteLabelSettings.cs | 15 +++++-------- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/config/appsettings.json b/config/appsettings.json index 91944f7e91..45b353f8cc 100644 --- a/config/appsettings.json +++ b/config/appsettings.json @@ -100,7 +100,9 @@ }, "controlpanel": { "url": "" - } + }, + "support-feedback": "https://helpdesk.onlyoffice.com", + "teamlab-site": "http://www.onlyoffice.com" }, "ConnectionStrings": { "default": { diff --git a/products/ASC.Files/Core/Helpers/Global.cs b/products/ASC.Files/Core/Helpers/Global.cs index c3a0dcf565..0eddddfa8a 100644 --- a/products/ASC.Files/Core/Helpers/Global.cs +++ b/products/ASC.Files/Core/Helpers/Global.cs @@ -417,7 +417,7 @@ namespace ASC.Web.Files.Classes id = my ? folderDao.GetFolderIDUser(true) : folderDao.GetFolderIDCommon(true); //Copy start document - if (AdditionalWhiteLabelSettings.Instance(SettingsManager).StartDocsEnabled) + if (SettingsManager.LoadForDefaultTenant().StartDocsEnabled) { try { diff --git a/products/ASC.Files/Core/Services/DocumentService/Configuration.cs b/products/ASC.Files/Core/Services/DocumentService/Configuration.cs index f5cb61acdf..231069778e 100644 --- a/products/ASC.Files/Core/Services/DocumentService/Configuration.cs +++ b/products/ASC.Files/Core/Services/DocumentService/Configuration.cs @@ -593,13 +593,14 @@ namespace ASC.Web.Files.Services.DocumentService set { } get { - if (CoreBaseSettings.Standalone) return null; - if (!AdditionalWhiteLabelSettings.Instance(SettingsManager).FeedbackAndSupportEnabled) return null; + if (CoreBaseSettings.Standalone) return null; + var settings = SettingsManager.LoadForDefaultTenant(); + if (!settings.FeedbackAndSupportEnabled) return null; return new FeedbackConfig { Url = BaseCommonLinkUtility.GetRegionalUrl( - AdditionalWhiteLabelSettings.Instance(SettingsManager).FeedbackAndSupportUrl, + settings.FeedbackAndSupportUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName), }; } diff --git a/web/ASC.Web.Api/Controllers/SettingsController.cs b/web/ASC.Web.Api/Controllers/SettingsController.cs index 95a9ce0913..8950e672cc 100644 --- a/web/ASC.Web.Api/Controllers/SettingsController.cs +++ b/web/ASC.Web.Api/Controllers/SettingsController.cs @@ -1821,6 +1821,28 @@ namespace ASC.Api.Settings return changed; } + [Read("payment")] + public object PaymentSettings() + { + var settings = SettingsManager.LoadForDefaultTenant(); + var currentQuota = TenantExtra.GetTenantQuota(); + var currentTariff = TenantExtra.GetCurrentTariff(); + + return + new + { + settings.SalesEmail, + settings.FeedbackAndSupportUrl, + settings.BuyUrl, + CoreBaseSettings.Standalone, + currentLicense = new + { + currentQuota.Trial, + currentTariff.DueDate.Date + } + }; + } + private readonly int maxCount = 10; private readonly int expirationMinutes = 2; private void CheckCache(string basekey) diff --git a/web/ASC.Web.Core/Notify/StudioNotifyService.cs b/web/ASC.Web.Core/Notify/StudioNotifyService.cs index bb0affa9e4..420acf0fa3 100644 --- a/web/ASC.Web.Core/Notify/StudioNotifyService.cs +++ b/web/ASC.Web.Core/Notify/StudioNotifyService.cs @@ -144,7 +144,7 @@ namespace ASC.Web.Studio.Core.Notify if (string.IsNullOrEmpty(site)) throw new ArgumentNullException("site"); message = (message ?? "").Trim(); - var salesEmail = AdditionalWhiteLabelSettings.Instance(SettingsManager).SalesEmail ?? SetupInfo.SalesEmail; + var salesEmail = SettingsManager.LoadForDefaultTenant().SalesEmail ?? SetupInfo.SalesEmail; var recipient = (IRecipient)(new DirectRecipient(AuthContext.CurrentAccount.ID.ToString(), string.Empty, new[] { salesEmail }, false)); diff --git a/web/ASC.Web.Core/Utility/CommonLinkUtility.cs b/web/ASC.Web.Core/Utility/CommonLinkUtility.cs index bdbe0c8695..8e06a8a33f 100644 --- a/web/ASC.Web.Core/Utility/CommonLinkUtility.cs +++ b/web/ASC.Web.Core/Utility/CommonLinkUtility.cs @@ -488,7 +488,7 @@ namespace ASC.Web.Studio.Utility public string GetHelpLink(SettingsManager settingsManager, AdditionalWhiteLabelSettingsHelper additionalWhiteLabelSettingsHelper, bool inCurrentCulture = true) { - if (!AdditionalWhiteLabelSettings.Instance(settingsManager).HelpCenterEnabled) + if (!settingsManager.LoadForDefaultTenant().HelpCenterEnabled) return string.Empty; var url = additionalWhiteLabelSettingsHelper.DefaultHelpCenterUrl; diff --git a/web/ASC.Web.Core/WhiteLabel/AdditionalWhiteLabelSettings.cs b/web/ASC.Web.Core/WhiteLabel/AdditionalWhiteLabelSettings.cs index f082779544..b67c3157ac 100644 --- a/web/ASC.Web.Core/WhiteLabel/AdditionalWhiteLabelSettings.cs +++ b/web/ASC.Web.Core/WhiteLabel/AdditionalWhiteLabelSettings.cs @@ -123,11 +123,6 @@ namespace ASC.Web.Core.WhiteLabel } } - public static AdditionalWhiteLabelSettings Instance(SettingsManager settingsManager) - { - return settingsManager.LoadForDefaultTenant(); - } - public ISettings GetDefault(IServiceProvider serviceProvider) { return GetDefault(serviceProvider.GetService()); @@ -147,7 +142,7 @@ namespace ASC.Web.Core.WhiteLabel { get { - var url = Configuration["web.help-center"]; + var url = Configuration["web:help-center"]; return string.IsNullOrEmpty(url) ? null : url; } } @@ -156,7 +151,7 @@ namespace ASC.Web.Core.WhiteLabel { get { - var url = Configuration["web.support-feedback"]; + var url = Configuration["web:support-feedback"]; return string.IsNullOrEmpty(url) ? null : url; } } @@ -165,7 +160,7 @@ namespace ASC.Web.Core.WhiteLabel { get { - var url = Configuration["web.user-forum"]; + var url = Configuration["web:user-forum"]; return string.IsNullOrEmpty(url) ? null : url; } } @@ -183,7 +178,7 @@ namespace ASC.Web.Core.WhiteLabel { get { - var email = Configuration["web.payment.email"]; + var email = Configuration["web:payment:email"]; return !string.IsNullOrEmpty(email) ? email : "sales@onlyoffice.com"; } } @@ -192,7 +187,7 @@ namespace ASC.Web.Core.WhiteLabel { get { - var site = Configuration["web.teamlab-site"]; + var site = Configuration["web:teamlab-site"]; return !string.IsNullOrEmpty(site) ? site + "/post.ashx?type=buyenterprise" : ""; } } From f464e031b88359b63ebf655bbfbb1af39d1a3ea6 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 11:42:13 +0300 Subject: [PATCH 2/7] Notify: fix --- .../Notify/Engine/NotifyEngine.cs | 26 +- .../Notify/Engine/NotifyRequest.cs | 22 +- products/ASC.Files/Core/ASC.Files.Core.csproj | 23 ++ .../Core/Configuration/ProductEntryPoint.cs | 14 +- .../FilesPatternResource.Designer.cs | 366 +++++++++--------- .../Services/NotifyService/NotifySource.cs | 2 +- .../Core/Services/NotifyService/patterns.xml | 38 +- products/ASC.Files/Server/Startup.cs | 4 +- .../Notify/NotifyConfiguration.cs | 15 +- 9 files changed, 280 insertions(+), 230 deletions(-) diff --git a/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs b/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs index 3ce113fbe7..23c6c7fe8d 100644 --- a/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs +++ b/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs @@ -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(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(); 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; diff --git a/common/ASC.Core.Common/Notify/Engine/NotifyRequest.cs b/common/ASC.Core.Common/Notify/Engine/NotifyRequest.cs index b5f634b794..12ae7ef5c3 100644 --- a/common/ASC.Core.Common/Notify/Engine/NotifyRequest.cs +++ b/common/ASC.Core.Common/Notify/Engine/NotifyRequest.cs @@ -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; } @@ -142,6 +142,26 @@ namespace ASC.Notify.Engine internal NoticeMessage CreateMessage(IDirectRecipient recipient) { 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(); } } } \ No newline at end of file diff --git a/products/ASC.Files/Core/ASC.Files.Core.csproj b/products/ASC.Files/Core/ASC.Files.Core.csproj index ca559f55d8..71f414e513 100644 --- a/products/ASC.Files/Core/ASC.Files.Core.csproj +++ b/products/ASC.Files/Core/ASC.Files.Core.csproj @@ -70,6 +70,29 @@ + + + True + True + FilesPatternResource.resx + + + + + + PublicResXFileCodeGenerator + FilesPatternResource.Designer.cs + + + + + + + + + + + FilesCommonResource.resx diff --git a/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs b/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs index 8fedfcdd6c..83a0c922af 100644 --- a/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs +++ b/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs @@ -36,7 +36,8 @@ 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 { public class ProductEntryPoint : Product @@ -60,14 +61,16 @@ namespace ASC.Web.Files.Configuration // FilesSpaceUsageStatManager filesSpaceUsageStatManager, CoreBaseSettings coreBaseSettings, AuthContext authContext, - UserManager userManager + UserManager userManager, + IServiceProvider serviceProvider // SubscriptionManager subscriptionManager ) { // FilesSpaceUsageStatManager = filesSpaceUsageStatManager; CoreBaseSettings = coreBaseSettings; AuthContext = authContext; - UserManager = userManager; + UserManager = userManager; + ServiceProvider = serviceProvider; //SubscriptionManager = subscriptionManager; } @@ -99,7 +102,9 @@ namespace ASC.Web.Files.Configuration AdminOpportunities = adminOpportunities, UserOpportunities = userOpportunities, CanNotBeDisabled = true, - }; + }; + + NotifyConfiguration.Configure(ServiceProvider); //SearchHandlerManager.Registry(new SearchHandler()); } @@ -175,6 +180,7 @@ namespace ASC.Web.Files.Configuration { if (services.TryAddScoped()) { + services.TryAddScoped(); return services .AddFilesSpaceUsageStatManagerService() .AddCoreBaseSettingsService() diff --git a/products/ASC.Files/Core/Services/NotifyService/FilesPatternResource.Designer.cs b/products/ASC.Files/Core/Services/NotifyService/FilesPatternResource.Designer.cs index 26bd68556b..fc9708b8bd 100644 --- a/products/ASC.Files/Core/Services/NotifyService/FilesPatternResource.Designer.cs +++ b/products/ASC.Files/Core/Services/NotifyService/FilesPatternResource.Designer.cs @@ -1,215 +1,215 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ASC.Web.Files.Services.NotifyService { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // 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.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class FilesPatternResource { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal FilesPatternResource() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - 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); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ASC.Web.Files.Services.NotifyService { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // 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", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class FilesPatternResource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal FilesPatternResource() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASC.Files.Core.Services.NotifyService.FilesPatternResource", typeof(FilesPatternResource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// /// Looks up a localized string similar to h1. All signers completed $Message /// ///This is a mail message to notify you that all signers completed "$DocumentTitle":"$DocumentURL". /// - ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. - /// - public static string pattern_DocuSignComplete { - get { - return ResourceManager.GetString("pattern_DocuSignComplete", resourceCulture); - } - } - - /// + ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. + /// + public static string pattern_DocuSignComplete { + get { + return ResourceManager.GetString("pattern_DocuSignComplete", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h1. $Message: $DocumentTitle /// ///Watch your DocuSign account for more information. /// - ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. - /// - public static string pattern_DocuSignStatus { - get { - return ResourceManager.GetString("pattern_DocuSignStatus", resourceCulture); - } - } - - /// + ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. + /// + public static string pattern_DocuSignStatus { + get { + return ResourceManager.GetString("pattern_DocuSignStatus", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h1. "$DocumentTitle":"$DocumentURL" /// ///This is a mail message to notify you that you have mentioned by "$__AuthorName":"$__AuthorUrl". /// ///$Message /// - ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. - /// - public static string pattern_EditorMentions { - get { - return ResourceManager.GetString("pattern_EditorMentions", resourceCulture); - } - } - - /// + ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. + /// + public static string pattern_EditorMentions { + get { + return ResourceManager.GetString("pattern_EditorMentions", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h1. Mailing completed /// ///This is a mail message to notify you that you have requested the mailing of $MailsCount messages and the process is now complete. $Message /// ///The successfully sent mail messages can be found in your "Sent":"$__VirtualRootPath/addons/mail/#sent" folder of the Mail module. /// - ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. - /// - public static string pattern_MailMergeEnd { - get { - return ResourceManager.GetString("pattern_MailMergeEnd", resourceCulture); - } - } - - /// + ///^You receive this email because you are a registered user of the "${__VirtualRootPath}":"${__VirtualRootPath}" portal.^. + /// + public static string pattern_MailMergeEnd { + get { + return ResourceManager.GetString("pattern_MailMergeEnd", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h1. Access granted to document: "$DocumentTitle":"$DocumentURL" /// ///$__DateTime "$__AuthorName":"$__AuthorUrl" granted you the access to the "$DocumentTitle":"$DocumentURL" document with the following access rights: "$AccessRights". /// - ///$Message. - /// - public static string pattern_ShareDocument { - get { - return ResourceManager.GetString("pattern_ShareDocument", resourceCulture); - } - } - - /// + ///$Message. + /// + public static string pattern_ShareDocument { + get { + return ResourceManager.GetString("pattern_ShareDocument", resourceCulture); + } + } + + /// /// Looks up a localized string similar to h1. Access granted to folder: "$DocumentTitle":"$__VirtualRootPath/products/files/#$FolderID" /// ///$__DateTime "$__AuthorName":"$__AuthorUrl" granted you the access to the "$DocumentTitle":"$__VirtualRootPath/products/files/#$FolderID" folder with the following access rights: "$AccessRights". /// - ///$Message. - /// - public static string pattern_ShareFolder { - get { - return ResourceManager.GetString("pattern_ShareFolder", resourceCulture); - } - } - - /// + ///$Message. + /// + public static string pattern_ShareFolder { + get { + return ResourceManager.GetString("pattern_ShareFolder", resourceCulture); + } + } + + /// /// Looks up a localized string similar to <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" se [rest of string was truncated]";. - /// - public static string patterns { - get { - return ResourceManager.GetString("patterns", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. All signers completed $DocumentTitle. - /// - public static string subject_DocuSignComplete { - get { - return ResourceManager.GetString("subject_DocuSignComplete", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. Sign status changed. - /// - public static string subject_DocuSignStatus { - get { - return ResourceManager.GetString("subject_DocuSignStatus", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. Mentioned in document. - /// - public static string subject_EditorMentions { - get { - return ResourceManager.GetString("subject_EditorMentions", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. Mailing is complete.. - /// - public static string subject_MailMergeEnd { - get { - return ResourceManager.GetString("subject_MailMergeEnd", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. Access granted to document: $DocumentTitle. - /// - public static string subject_ShareDocument { - get { - return ResourceManager.GetString("subject_ShareDocument", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documents. Access granted to folder: $DocumentTitle. - /// - public static string subject_ShareFolder { - get { - return ResourceManager.GetString("subject_ShareFolder", resourceCulture); - } - } - } -} + /// <pattern id="DocuSignComplete" send [rest of string was truncated]";. + /// + public static string patterns { + get { + return ResourceManager.GetString("patterns", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. All signers completed $DocumentTitle. + /// + public static string subject_DocuSignComplete { + get { + return ResourceManager.GetString("subject_DocuSignComplete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. Sign status changed. + /// + public static string subject_DocuSignStatus { + get { + return ResourceManager.GetString("subject_DocuSignStatus", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. Mentioned in document. + /// + public static string subject_EditorMentions { + get { + return ResourceManager.GetString("subject_EditorMentions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. Mailing is complete.. + /// + public static string subject_MailMergeEnd { + get { + return ResourceManager.GetString("subject_MailMergeEnd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. Access granted to document: $DocumentTitle. + /// + public static string subject_ShareDocument { + get { + return ResourceManager.GetString("subject_ShareDocument", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Documents. Access granted to folder: $DocumentTitle. + /// + public static string subject_ShareFolder { + get { + return ResourceManager.GetString("subject_ShareFolder", resourceCulture); + } + } + } +} diff --git a/products/ASC.Files/Core/Services/NotifyService/NotifySource.cs b/products/ASC.Files/Core/Services/NotifyService/NotifySource.cs index 02115c0e15..196e19cd0e 100644 --- a/products/ASC.Files/Core/Services/NotifyService/NotifySource.cs +++ b/products/ASC.Files/Core/Services/NotifyService/NotifySource.cs @@ -28,7 +28,7 @@ using System; using ASC.Common; using ASC.Core; -using ASC.Core.Notify; +using ASC.Core.Notify; using ASC.Notify.Model; using ASC.Notify.Patterns; using ASC.Notify.Recipients; diff --git a/products/ASC.Files/Core/Services/NotifyService/patterns.xml b/products/ASC.Files/Core/Services/NotifyService/patterns.xml index ea52f60624..6d721e461c 100644 --- a/products/ASC.Files/Core/Services/NotifyService/patterns.xml +++ b/products/ASC.Files/Core/Services/NotifyService/patterns.xml @@ -1,30 +1,30 @@ - + - - + + - + $DocumentURL - - + + - + $Message: $DocumentTitle - - + + - + $__AuthorName $Message @@ -32,11 +32,11 @@ $Message - - + + - + $__AuthorName $AccessRights @@ -48,11 +48,11 @@ $DocumentURL - - + + - + $__AuthorName $AccessRights @@ -64,11 +64,11 @@ $__VirtualRootPath/products/files/#$FolderID - - + + - + $__AuthorName $DocumentTitle diff --git a/products/ASC.Files/Server/Startup.cs b/products/ASC.Files/Server/Startup.cs index 56c3d99689..591bd3d13e 100644 --- a/products/ASC.Files/Server/Startup.cs +++ b/products/ASC.Files/Server/Startup.cs @@ -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); } diff --git a/web/ASC.Web.Core/Notify/NotifyConfiguration.cs b/web/ASC.Web.Core/Notify/NotifyConfiguration.cs index dd2bb7ac2c..be3086716f 100644 --- a/web/ASC.Web.Core/Notify/NotifyConfiguration.cs +++ b/web/ASC.Web.Core/Notify/NotifyConfiguration.cs @@ -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().GetCurrentTenant(); - var authContext = serviceScope.ServiceProvider.GetService(); - var userManager = serviceScope.ServiceProvider.GetService(); - var displayUserSettingsHelper = serviceScope.ServiceProvider.GetService(); + var tenant = scope.ServiceProvider.GetService().GetCurrentTenant(); + var authContext = scope.ServiceProvider.GetService(); + var userManager = scope.ServiceProvider.GetService(); + var displayUserSettingsHelper = scope.ServiceProvider.GetService(); if (authContext.IsAuthenticated) { @@ -262,9 +262,7 @@ namespace ASC.Web.Studio.Core.Notify .Replace("<", "<"); } } - using var scope = ServiceProvider.CreateScope(); var tenantExtra = scope.ServiceProvider.GetService(); - var webItemManagerSecurity = scope.ServiceProvider.GetService(); var webItemManager = scope.ServiceProvider.GetService(); var configuration = scope.ServiceProvider.GetService(); var tenantLogoManager = scope.ServiceProvider.GetService(); @@ -390,7 +388,8 @@ namespace ASC.Web.Studio.Core.Notify .AddCoreBaseSettingsService() .AddAdditionalWhiteLabelSettingsService() .AddCommonLinkUtilityService() - .AddMailWhiteLabelSettingsService(); + .AddMailWhiteLabelSettingsService() + .AddStudioNotifyHelperService(); } } } From 187e5de648e60290da7757ccb32b9a9b72fea691 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 16:10:18 +0300 Subject: [PATCH 3/7] TagDao: fix --- products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs index 27beb1ecf5..81ebf673be 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs @@ -201,11 +201,10 @@ namespace ASC.Files.Core.Data .Where(r => r.TagId == row.Link.TagId) .Where(r => r.EntryId == row.Link.EntryId) .Where(r => r.EntryType == row.Link.EntryType); - FilesDbContext.TagLink.RemoveRange(linksToRemove); + FilesDbContext.TagLink.RemoveRange(linksToRemove); + FilesDbContext.SaveChanges(); } - FilesDbContext.SaveChanges(); - var tagsToRemove = Query(FilesDbContext.Tag) .Where(r => !Query(FilesDbContext.TagLink).Where(a => a.TagId == r.Id).Any()); From f8b3382a425d5e61e9a4f078fe9cd889becb08e4 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 16:22:45 +0300 Subject: [PATCH 4/7] Files: tagDao. Fix --- products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs index 81ebf673be..33bcf432fd 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs @@ -200,11 +200,13 @@ namespace ASC.Files.Core.Data var linksToRemove = Query(FilesDbContext.TagLink) .Where(r => r.TagId == row.Link.TagId) .Where(r => r.EntryId == row.Link.EntryId) - .Where(r => r.EntryType == row.Link.EntryType); - FilesDbContext.TagLink.RemoveRange(linksToRemove); - FilesDbContext.SaveChanges(); + .Where(r => r.EntryType == row.Link.EntryType) + .ToList(); + FilesDbContext.TagLink.RemoveRange(linksToRemove); } + FilesDbContext.SaveChanges(); + var tagsToRemove = Query(FilesDbContext.Tag) .Where(r => !Query(FilesDbContext.TagLink).Where(a => a.TagId == r.Id).Any()); From 92a72d7983e5571485d51e3ffa7cc230ddd4b831 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 16:33:39 +0300 Subject: [PATCH 5/7] Files: Tag. Fix --- products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs index 33bcf432fd..6c34f1cf5e 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs @@ -193,7 +193,8 @@ namespace ASC.Files.Core.Data Query(FilesDbContext.Tag) .Join(FilesDbContext.TagLink, r => r.Id, l => l.TagId, (tag, link) => new TagLinkData { Tag = tag, Link = link }) .Where(r => r.Link.TenantId == r.Tag.TenantId) - .Where(r => r.Tag.Flag == TagType.New && r.Link.CreateOn <= TenantUtil.DateTimeNow().AddMonths(-1)); + .Where(r => r.Tag.Flag == TagType.New && r.Link.CreateOn <= TenantUtil.DateTimeNow().AddMonths(-1)) + .ToList(); foreach (var row in mustBeDeleted) { From ad51a6bf2989fe32e461433ac8313e91fac46a32 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 17:00:29 +0300 Subject: [PATCH 6/7] Files: fix --- products/ASC.Files/Core/Configuration/ProductEntryPoint.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs b/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs index 83a0c922af..85555708f1 100644 --- a/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs +++ b/products/ASC.Files/Core/Configuration/ProductEntryPoint.cs @@ -104,8 +104,10 @@ namespace ASC.Web.Files.Configuration CanNotBeDisabled = true, }; - NotifyConfiguration.Configure(ServiceProvider); - + if (ServiceProvider != null) + { + NotifyConfiguration.Configure(ServiceProvider); + } //SearchHandlerManager.Registry(new SearchHandler()); } From c87fd2cfdbc551d4bc3435d2656ff9e8da526690 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Tue, 8 Sep 2020 17:36:22 +0300 Subject: [PATCH 7/7] Files: share fix --- .../ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs b/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs index 21d1d6e227..9698d9f72f 100644 --- a/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs +++ b/products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs @@ -354,9 +354,14 @@ namespace ASC.Files.Core.Data private FileShareRecord ToFileShareRecord(SecurityTreeRecord r) { - var result = ToFileShareRecord(r.DbFilesSecurity); - result.EntryId = r.DbFolderTree?.FolderId; - result.Level = r.DbFolderTree?.Level ?? -1; + var result = ToFileShareRecord(r.DbFilesSecurity); + if (r.DbFolderTree != null) + { + result.EntryId = r.DbFolderTree.FolderId; + } + + result.Level = r.DbFolderTree?.Level ?? -1; + return result; } }