Merge branch 'develop' into feature/room-security

This commit is contained in:
Maksim Chegulov 2022-09-06 13:36:03 +03:00
commit fb4e996196
409 changed files with 1737 additions and 625 deletions

View File

@ -28,19 +28,21 @@ namespace ASC.Api.Core;
public class BaseWorkerStartup
{
private readonly IConfiguration _configuration;
private readonly IHostEnvironment _hostEnvironment;
protected IConfiguration Configuration { get; }
protected IHostEnvironment HostEnvironment { get; }
protected DIHelper DIHelper { get; }
public BaseWorkerStartup(IConfiguration configuration, IHostEnvironment hostEnvironment)
{
_configuration = configuration;
_hostEnvironment = hostEnvironment;
Configuration = configuration;
HostEnvironment = hostEnvironment;
DIHelper = new DIHelper();
}
public virtual void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddCustomHealthCheck(_configuration);
services.AddCustomHealthCheck(Configuration);
services.AddScoped<EFLoggerFactory>();
services.AddBaseDbContextPool<AccountLinkContext>();
@ -58,12 +60,22 @@ public class BaseWorkerStartup
services.AddAutoMapper(GetAutoMapperProfileAssemblies());
if (!_hostEnvironment.IsDevelopment())
if (!HostEnvironment.IsDevelopment())
{
services.AddStartupTask<WarmupServicesStartupTask>()
.TryAddSingleton(services);
}
services.AddMemoryCache();
services.AddDistributedCache(Configuration);
services.AddEventBus(Configuration);
services.AddDistributedTaskQueue();
services.AddCacheNotify(Configuration);
DIHelper.Configure(services);
}
private IEnumerable<Assembly> GetAutoMapperProfileAssemblies()

View File

@ -0,0 +1,64 @@
// (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.Api.Core.Extensions;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddDefaultConfiguration(
this ConfigurationManager config,
IHostEnvironment env
)
{
var path = config["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(env.ContentRootPath, path));
}
config.SetBasePath(path);
config.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
});
config.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env.EnvironmentName}.json", true)
.AddJsonFile("rabbitmq.json")
.AddJsonFile($"rabbitmq.{env.EnvironmentName}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env.EnvironmentName}.json", true);
return config;
}
}

View File

@ -27,76 +27,14 @@
namespace ASC.Api.Core.Extensions;
public static class HostBuilderExtension
{
public static IHostBuilder ConfigureDefault(this IHostBuilder hostBuilder, string[] args,
Action<HostBuilderContext, IConfigurationBuilder, IHostEnvironment, string> configureApp = null,
Action<HostBuilderContext, IServiceCollection, DIHelper> configureServices = null)
{
{
public static IHostBuilder ConfigureDefault(this IHostBuilder hostBuilder)
{
hostBuilder.UseSystemd();
hostBuilder.UseWindowsService();
hostBuilder.UseServiceProviderFactory(new AutofacServiceProviderFactory());
hostBuilder.ConfigureDefaultAppConfiguration(args, configureApp);
hostBuilder.ConfigureDefaultServices(configureServices);
hostBuilder.UseServiceProviderFactory(new AutofacServiceProviderFactory());
hostBuilder.ConfigureNLogLogging();
return hostBuilder;
}
public static IHostBuilder ConfigureDefaultAppConfiguration(this IHostBuilder hostBuilder, string[] args, Action<HostBuilderContext, IConfigurationBuilder, IHostEnvironment, string> configureDelegate = null)
{
hostBuilder.ConfigureAppConfiguration((hostContext, config) =>
{
var buildedConfig = config.Build();
var path = buildedConfig["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
var env = hostContext.HostingEnvironment;
config.SetBasePath(path);
config.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env.EnvironmentName}.json", true)
.AddJsonFile("rabbitmq.json")
.AddJsonFile($"rabbitmq.{env.EnvironmentName}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env.EnvironmentName}.json", true);
configureDelegate?.Invoke(hostContext, config, env, path);
config.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
});
});
return hostBuilder;
}
public static IHostBuilder ConfigureDefaultServices(this IHostBuilder hostBuilder, Action<HostBuilderContext, IServiceCollection, DIHelper> configureDelegate)
{
hostBuilder.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
services.AddDistributedCache(hostContext.Configuration);
services.AddEventBus(hostContext.Configuration);
services.AddDistributedTaskQueue();
services.AddCacheNotify(hostContext.Configuration);
var diHelper = new DIHelper(services);
configureDelegate?.Invoke(hostContext, services, diHelper);
});
return hostBuilder;
return hostBuilder;
}
}

View File

@ -32,7 +32,11 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args);
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.WebHost.ConfigureDefaultKestrel();
var startup = new Startup(builder.Configuration, builder.Environment);

View File

@ -0,0 +1,41 @@
// (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.ClearEvents.Extensions;
public static class ServiceCollectionExtension
{
public static IServiceCollection AddClearEventsServices(this IServiceCollection services)
{
var diHelper = new DIHelper(services);
services.AddHostedService<ClearEventsService>();
diHelper.TryAdd<ClearEventsService>();
services.AddBaseDbContextPool<MessagesContext>();
return services;
}
}

View File

@ -43,3 +43,4 @@ global using Microsoft.AspNetCore.Builder;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.Extensions.Hosting.WindowsServices;
global using Microsoft.Extensions.Logging;
global using ASC.ClearEvents.Extensions;

View File

@ -32,12 +32,13 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, null, (hostContext, services, diHelper) =>
{
services.AddHostedService<ClearEventsService>();
diHelper.TryAdd<ClearEventsService>();
services.AddBaseDbContextPool<MessagesContext>();
});
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.Services.AddClearEventsServices();
builder.Host.ConfigureContainer<ContainerBuilder>((context, builder) =>
{

View File

@ -0,0 +1,41 @@
// (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.Data.Backup.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddBackupBackgroundTasksConfiguration(
this ConfigurationManager config,
IHostEnvironment env)
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true)
.AddJsonFile("backup.json");
return config;
}
}

View File

@ -24,6 +24,8 @@
// 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
using ASC.Data.Backup.Extension;
var options = new WebApplicationOptions
{
Args = args,
@ -31,18 +33,14 @@ var options = new WebApplicationOptions
};
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true)
.AddJsonFile("backup.json");
}, (ctx, ser, di) =>
{
ser.AddBaseDbContextPool<BackupsContext>();
ser.AddBaseDbContextPool<FilesDbContext>();
});
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddBackupBackgroundTasksConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.WebHost.ConfigureDefaultKestrel();
var startup = new Startup(builder.Configuration, builder.Environment);

View File

@ -67,7 +67,10 @@ public class Startup : BaseStartup
services.AddHostedService<BackupWorkerService>();
services.AddActivePassiveHostedService<BackupCleanerService>();
services.AddActivePassiveHostedService<BackupSchedulerService>();
services.AddActivePassiveHostedService<BackupSchedulerService>();
services.AddBaseDbContextPool<BackupsContext>();
services.AddBaseDbContextPool<FilesDbContext>();
}
}

View File

@ -0,0 +1,40 @@
// (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.Data.Backup.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddBackupConfiguration(
this ConfigurationManager config,
IHostEnvironment env)
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
return config;
}
}

View File

@ -24,6 +24,8 @@
// 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
using ASC.Data.Backup.Extension;
var options = new WebApplicationOptions
{
Args = args,
@ -32,15 +34,12 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
}, (ctx, ser, di) =>
{
ser.AddBaseDbContextPool<BackupsContext>();
ser.AddBaseDbContextPool<FilesDbContext>();
});
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddBackupConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.WebHost.ConfigureDefaultKestrel();

View File

@ -38,12 +38,14 @@ public class Startup : BaseStartup
{
base.ConfigureServices(services);
services.AddBaseDbContextPool<BackupsContext>();
services.AddBaseDbContextPool<FilesDbContext>();
DIHelper.TryAdd<BackupProgressItem>();
DIHelper.TryAdd<RestoreProgressItem>();
DIHelper.TryAdd<TransferProgressItem>();
NotifyConfigurationExtension.Register(DIHelper);
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)

View File

@ -0,0 +1,42 @@
// (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.Notify.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddNotifyConfiguration(
this ConfigurationManager config,
IHostEnvironment env)
{
config.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
return config;
}
}

View File

@ -63,3 +63,5 @@ global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Newtonsoft.Json;
global using ASC.Notify;
global using ASC.Notify.Extension;

View File

@ -32,37 +32,13 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
},
(hostContext, services, diHelper) =>
{
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddNotifyConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
services.Configure<NotifyServiceCfg>(hostContext.Configuration.GetSection("notify"));
diHelper.TryAdd<NotifySenderService>();
diHelper.TryAdd<NotifyCleanerService>();
diHelper.TryAdd<TenantManager>();
diHelper.TryAdd<TenantWhiteLabelSettingsHelper>();
diHelper.TryAdd<SettingsManager>();
diHelper.TryAdd<JabberSender>();
diHelper.TryAdd<SmtpSender>();
diHelper.TryAdd<AWSSender>(); // fix private
diHelper.TryAdd<NotifyInvokeSendMethodRequestedIntegrationEventHandler>();
diHelper.TryAdd<NotifySendMessageRequestedIntegrationEventHandler>();
services.AddActivePassiveHostedService<NotifySenderService>();
services.AddActivePassiveHostedService<NotifyCleanerService>();
services.AddBaseDbContextPool<NotifyDbContext>();
});
var startup = new BaseWorkerStartup(builder.Configuration, builder.Environment);
var startup = new Startup(builder.Configuration, builder.Environment);
startup.ConfigureServices(builder.Services);

View File

@ -0,0 +1,60 @@
// (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.Notify;
public class Startup : BaseWorkerStartup
{
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment) : base(configuration, hostEnvironment)
{
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
DIHelper.RegisterProducts(Configuration, HostEnvironment.ContentRootPath);
services.Configure<NotifyServiceCfg>(Configuration.GetSection("notify"));
DIHelper.TryAdd<NotifySenderService>();
DIHelper.TryAdd<NotifyCleanerService>();
DIHelper.TryAdd<TenantManager>();
DIHelper.TryAdd<TenantWhiteLabelSettingsHelper>();
DIHelper.TryAdd<SettingsManager>();
DIHelper.TryAdd<JabberSender>();
DIHelper.TryAdd<SmtpSender>();
DIHelper.TryAdd<AWSSender>(); // fix private
DIHelper.TryAdd<NotifyInvokeSendMethodRequestedIntegrationEventHandler>();
DIHelper.TryAdd<NotifySendMessageRequestedIntegrationEventHandler>();
services.AddActivePassiveHostedService<NotifySenderService>();
services.AddActivePassiveHostedService<NotifyCleanerService>();
services.AddBaseDbContextPool<NotifyDbContext>();
}
}

View File

@ -0,0 +1,42 @@
// (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.Notify.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddStudioNotifyConfiguration(
this ConfigurationManager config,
IHostEnvironment env)
{
config.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
return config;
}
}

View File

@ -24,6 +24,8 @@
// 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
using ASC.Notify.Extension;
var options = new WebApplicationOptions
{
Args = args,
@ -32,26 +34,15 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
},
(hostContext, services, diHelper) =>
{
services.AddHttpClient();
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<ServiceLauncher>();
diHelper.TryAdd<ServiceLauncher>();
NotifyConfigurationExtension.Register(diHelper);
diHelper.TryAdd<EmailSenderSink>();
});
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddStudioNotifyConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.WebHost.ConfigureDefaultKestrel();
var startup = new BaseWorkerStartup(builder.Configuration, builder.Environment);
var startup = new Startup(builder.Configuration, builder.Environment);
startup.ConfigureServices(builder.Services);

View File

@ -0,0 +1,47 @@
// (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
public class Startup : BaseWorkerStartup
{
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
: base(configuration, hostEnvironment)
{
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
services.AddHttpClient();
DIHelper.RegisterProducts(Configuration, HostEnvironment.ContentRootPath);
services.AddHostedService<ServiceLauncher>();
DIHelper.TryAdd<ServiceLauncher>();
NotifyConfigurationExtension.Register(DIHelper);
DIHelper.TryAdd<EmailSenderSink>();
}
}

View File

@ -0,0 +1,40 @@
// (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.TelegramService.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddTelegramConfiguration(
this ConfigurationManager config,
IHostEnvironment env)
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
return config;
}
}

View File

@ -58,3 +58,4 @@ global using Telegram.Bot;
global using Telegram.Bot.Exceptions;
global using Telegram.Bot.Types;
global using Telegram.Bot.Types.Enums;
global using ASC.TelegramService.Extension;

View File

@ -32,11 +32,11 @@ var options = new WebApplicationOptions
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile("notify.json")
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
});
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddTelegramConfiguration(builder.Environment)
.AddEnvironmentVariables()
.AddCommandLine(args);
builder.WebHost.ConfigureDefaultKestrel();

View File

@ -0,0 +1,38 @@
// (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.Webhooks.Extension;
public static class ConfigurationManagerExtension
{
public static ConfigurationManager AddWebhookConfiguration(
this ConfigurationManager config)
{
config.AddJsonFile($"appsettings.services.json", true);
return config;
}
}

View File

@ -46,4 +46,6 @@ global using Microsoft.Extensions.Hosting.WindowsServices;
global using Microsoft.Extensions.Logging;
global using Polly;
global using Polly.Extensions.Http;
global using Polly.Extensions.Http;
global using ASC.Webhooks.Extension;

View File

@ -31,35 +31,17 @@ var options = new WebApplicationOptions
};
var builder = WebApplication.CreateBuilder(options);
builder.Host.ConfigureDefault(args, (hostContext, config, env, path) =>
{
config.AddJsonFile($"appsettings.services.json", true);
}, (hostContext, services, diHelper) =>
{
services.AddHttpClient();
diHelper.TryAdd<DbWorker>();
services.AddHostedService<WorkerService>();
diHelper.TryAdd<WorkerService>();
services.AddHttpClient("webhook")
.SetHandlerLifetime(TimeSpan.FromMinutes(5))
.AddPolicyHandler((s, request) =>
{
var settings = s.GetRequiredService<Settings>();
builder.Host.ConfigureDefault();
builder.Configuration.AddDefaultConfiguration(builder.Environment)
.AddWebhookConfiguration()
.AddEnvironmentVariables()
.AddCommandLine(args);
return HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
.WaitAndRetryAsync(settings.RepeatCount.HasValue ? settings.RepeatCount.Value : 5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
});
});
builder.WebHost.ConfigureDefaultKestrel();
var startup = new BaseWorkerStartup(builder.Configuration, builder.Environment);
var startup = new Startup(builder.Configuration, builder.Environment);
startup.ConfigureServices(builder.Services);

View File

@ -0,0 +1,59 @@
// (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.Webhooks.Service;
public class Startup : BaseWorkerStartup
{
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment) :
base(configuration, hostEnvironment)
{
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
services.AddHttpClient();
DIHelper.TryAdd<DbWorker>();
services.AddHostedService<WorkerService>();
DIHelper.TryAdd<WorkerService>();
services.AddHttpClient("webhook")
.SetHandlerLifetime(TimeSpan.FromMinutes(5))
.AddPolicyHandler((s, request) =>
{
var settings = s.GetRequiredService<Settings>();
return HttpPolicyExtensions
.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
.WaitAndRetryAsync(settings.RepeatCount.HasValue ? settings.RepeatCount.Value : 5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
});
}
}

View File

@ -111,7 +111,7 @@
"url": "/socket.io",
"internal": "http://localhost:9899/"
},
"cultures": "az,cs,el,es,fr,ja,lo,nl,pt,ro,sk,tr,vi,bg,de,en,fi,it,ko,lv,pl,pt-BR,ru,sl,uk,zh-CN",
"cultures": "az,cs,el-GR,es,fr,ja-JP,lo-LA,nl,pt,ro,sk,tr,vi,bg,de,en-US,en-GB,fi,it,ko-KR,lv,pl,pt-BR,ru,sl,uk-UA,zh-CN",
"url-shortener": {
"value": "/sh/",
"internal": "http://localhost:9999/"

View File

@ -70,6 +70,10 @@
"DataBackup": "Data backup",
"DeactivateOrDeletePortal": "Deactivate or delete portal.",
"Disabled": "Disabled",
"DNSSettings": "DNS Settings",
"DNSSettingsDescription": "DNS Settings is a way to set an alternative URL for your portal.",
"DNSSettingsMobile": "Send your request to our support team, and our specialists will help you with the settings.",
"DNSSettingsTooltip": "DNS Settings allow you to set an alternative URL address for your ONLYOFFICE portal. Send your request to our support team, and our specialists will help you with the settings.<2>{{learnMore}}</2>",
"DocumentsAdministratorsCan": "Documents administrators can link Dropbox, Box, and other accounts to Common Documents and set up access rights in this section",
"DownloadCopy": "Download the copy",
"DownloadReportBtn": "Download and open report",
@ -202,5 +206,6 @@
"UserAgreement": "I confirm and want to proceed",
"Users": "Users",
"WhiteLabel": "White label",
"YouHaveUnsavedChanges": "You have unsaved changes"
"YouHaveUnsavedChanges": "You have unsaved changes",
"YourCurrentDomain": "Your current domain"
}

Some files were not shown because too many files have changed in this diff Show More