Browse Source

Files moved to correct place.

pull/492/head
Sebastian 7 years ago
parent
commit
87459c228f
  1. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/INotificationEmailSender.cs
  2. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NoopNotificationEmailSender.cs
  3. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailEventConsumer.cs
  4. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailSender.cs
  5. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailTextOptions.cs
  6. 10
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContextExtensions.cs
  7. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs
  8. 45
      backend/src/Squidex.Infrastructure/Email/SmtpEmailSender.cs
  9. 61
      backend/src/Squidex.Infrastructure/Log/JsonLogWriterFactory.cs
  10. 1
      backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
  11. 2
      backend/src/Squidex/Config/Domain/NotificationsServices.cs
  12. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Invitation/Notifications/NotificationEmailEventConsumerTests.cs
  13. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Invitation/Notifications/NotificationEmailSenderTests.cs

2
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/INotificationEmailSender.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/INotificationEmailSender.cs

@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public interface INotificationEmailSender
{

2
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NoopNotificationEmailSender.cs

@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public sealed class NoopNotificationEmailSender : INotificationEmailSender
{

2
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailEventConsumer.cs

@ -13,7 +13,7 @@ using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public sealed class NotificationEmailEventConsumer : IEventConsumer
{

2
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailSender.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailSender.cs

@ -12,7 +12,7 @@ using Squidex.Infrastructure.Email;
using Squidex.Infrastructure.Log;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public sealed class NotificationEmailSender : INotificationEmailSender
{

2
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailTextOptions.cs → backend/src/Squidex.Domain.Apps.Entities/Apps/Invitation/Notifications/NotificationEmailTextOptions.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public sealed class NotificationEmailTextOptions
{

10
backend/src/Squidex.Domain.Apps.Entities/Contents/ContextExtensions.cs

@ -39,6 +39,11 @@ namespace Squidex.Domain.Apps.Entities.Contents
cache.AddHeader(HeaderUnpublished);
}
public static SearchScope Scope(this Context context)
{
return context.ShouldProvideUnpublished() || context.IsFrontendClient ? SearchScope.All : SearchScope.Published;
}
public static bool ShouldCleanup(this Context context)
{
return !context.Headers.ContainsKey(HeaderNoCleanup);
@ -99,11 +104,6 @@ namespace Squidex.Domain.Apps.Entities.Contents
return SetBoolean(context, HeaderNoResolveLanguages, value);
}
public static SearchScope Scope(this Context context)
{
return context.ShouldProvideUnpublished() || context.IsFrontendClient ? SearchScope.All : SearchScope.Published;
}
public static IEnumerable<string> AssetUrls(this Context context)
{
if (context.Headers.TryGetValue(HeaderResolveUrls, out var value))

4
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/GraphQLExecutionContext.cs

@ -31,7 +31,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL
public ISemanticLog Log { get; }
public GraphQLExecutionContext(Context context, IDependencyResolver resolver)
: base(context,
: base(context
.WithoutCleanup()
.WithoutContentEnrichment(),
resolver.Resolve<IAssetQueryService>(),
resolver.Resolve<IContentQueryService>())
{

45
backend/src/Squidex.Infrastructure/Email/SmtpEmailSender.cs

@ -9,6 +9,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;
using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options;
namespace Squidex.Infrastructure.Email
@ -17,27 +18,55 @@ namespace Squidex.Infrastructure.Email
public sealed class SmtpEmailSender : IEmailSender
{
private readonly SmptOptions options;
private readonly ObjectPool<SmtpClient> pool;
internal sealed class SmtpClientPolicy : PooledObjectPolicy<SmtpClient>
{
private readonly SmptOptions options;
public SmtpClientPolicy(SmptOptions options)
{
this.options = options;
}
public override SmtpClient Create()
{
return new SmtpClient(options.Server, options.Port)
{
Credentials = new NetworkCredential(
options.Username,
options.Password),
EnableSsl = options.EnableSsl
};
}
public override bool Return(SmtpClient obj)
{
return true;
}
}
public SmtpEmailSender(IOptions<SmptOptions> options)
{
Guard.NotNull(options);
this.options = options.Value;
pool = new DefaultObjectPoolProvider().Create(new SmtpClientPolicy(options.Value));
}
public async Task SendAsync(string recipient, string subject, string body)
{
using (var smtpClient = new SmtpClient(options.Server, options.Port)
{
Credentials = new NetworkCredential(
options.Username,
options.Password),
EnableSsl = options.EnableSsl
})
var smtpClient = pool.Get();
try
{
await smtpClient.SendMailAsync(options.Sender, recipient, subject, body);
}
finally
{
pool.Return(smtpClient);
}
}
}
}

61
backend/src/Squidex.Infrastructure/Log/JsonLogWriterFactory.cs

@ -5,24 +5,49 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.Concurrent;
using System.Text.Json;
using Microsoft.Extensions.ObjectPool;
namespace Squidex.Infrastructure.Log
{
public sealed class JsonLogWriterFactory : IObjectWriterFactory
{
private const int MaxPoolSize = 10;
private const int MaxCapacity = 5000;
private readonly ConcurrentStack<JsonLogWriter> pool = new ConcurrentStack<JsonLogWriter>();
private readonly JsonWriterOptions formatting;
private readonly bool formatLine;
private readonly ObjectPool<JsonLogWriter> pool;
public JsonLogWriterFactory(bool indended = false, bool formatLine = false)
internal sealed class JsonLogWriterPolicy : PooledObjectPolicy<JsonLogWriter>
{
formatting.Indented = indended;
private const int MaxCapacity = 5000;
private readonly JsonWriterOptions formatting;
private readonly bool formatLine;
public JsonLogWriterPolicy(bool indended = false, bool formatLine = false)
{
formatting.Indented = indended;
this.formatLine = formatLine;
}
public override JsonLogWriter Create()
{
return new JsonLogWriter(formatting, formatLine);
}
public override bool Return(JsonLogWriter obj)
{
if (obj.BufferSize > MaxCapacity)
{
return false;
}
obj.Reset();
return true;
}
}
this.formatLine = formatLine;
public JsonLogWriterFactory(bool indended = false, bool formatLine = false)
{
pool = new DefaultObjectPoolProvider().Create(new JsonLogWriterPolicy(indended, formatLine));
}
public static JsonLogWriterFactory Default()
@ -37,26 +62,12 @@ namespace Squidex.Infrastructure.Log
public IObjectWriter Create()
{
if (pool.TryPop(out var writer))
{
writer.Reset();
}
else
{
writer = new JsonLogWriter(formatting, formatLine);
}
return writer;
return pool.Get();
}
public void Release(IObjectWriter writer)
{
var jsonWriter = (JsonLogWriter)writer;
if (pool.Count < MaxPoolSize && jsonWriter.BufferSize < MaxCapacity)
{
pool.Push(jsonWriter);
}
pool.Return((JsonLogWriter)writer);
}
}
}

1
backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj

@ -19,6 +19,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="3.1.2" />
<PackageReference Include="Microsoft.OData.Core" Version="7.6.3" />
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.0.2">
<PrivateAssets>all</PrivateAssets>

2
backend/src/Squidex/Config/Domain/NotificationsServices.cs

@ -8,7 +8,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Squidex.Domain.Apps.Entities.History.Notifications;
using Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications;
using Squidex.Infrastructure.Email;
using Squidex.Infrastructure.EventSourcing;

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/History/Notifications/NotificationEmailEventConsumerTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Invitation/Notifications/NotificationEmailEventConsumerTests.cs

@ -16,7 +16,7 @@ using Squidex.Infrastructure.Log;
using Squidex.Shared.Users;
using Xunit;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public class NotificationEmailEventConsumerTests
{

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/History/Notifications/NotificationEmailSenderTests.cs → backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Invitation/Notifications/NotificationEmailSenderTests.cs

@ -18,7 +18,7 @@ using Squidex.Shared.Identity;
using Squidex.Shared.Users;
using Xunit;
namespace Squidex.Domain.Apps.Entities.History.Notifications
namespace Squidex.Domain.Apps.Entities.Apps.Invitation.Notifications
{
public class NotificationEmailSenderTests
{
Loading…
Cancel
Save