Skip to content

Commit

Permalink
Update MJML and closes #199
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Aug 17, 2023
1 parent dbbe3dd commit 1c2e30e
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.100.147" />
<PackageReference Include="Confluent.Kafka" Version="2.1.1" />
<PackageReference Include="FirebaseAdmin" Version="2.3.0" />
<PackageReference Include="FluentValidation" Version="11.5.2" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.200.16" />
<PackageReference Include="Confluent.Kafka" Version="2.2.0" />
<PackageReference Include="FirebaseAdmin" Version="2.4.0" />
<PackageReference Include="FluentValidation" Version="11.7.1" />
<PackageReference Include="Fluid.Core" Version="2.4.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.48" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.14" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.51" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.18" />
<PackageReference Include="Mailjet.Api" Version="3.0.0" />
<PackageReference Include="MailKit" Version="4.1.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="OpenNotifications" Version="0.2.0" />
<PackageReference Include="OpenNotifications" Version="0.3.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
<PackageReference Include="Twilio" Version="6.9.0" />
<PackageReference Include="Twilio" Version="6.11.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ public ValueTask<EmailTemplate> ParseAsync(EmailTemplate input, bool strict,
throw new EmailFormattingException(context.Errors);
}

if (!string.IsNullOrWhiteSpace(input.BodyHtml))
{
input = input with
{
BodyHtml = MjmlRenderer.FixXML(input.BodyHtml)
};
}

return new ValueTask<EmailTemplate>(input);
}

Expand Down Expand Up @@ -149,7 +141,7 @@ private static EmailMessage Format(EmailTemplate template, EmailContext context,

context.ValidateTemplate(result, EmailTemplateType.BodyHtml);

var (rendered, errors) = MjmlRenderer.Render(result, strict, true);
var (rendered, errors) = MjmlRenderer.Render(result, strict);

foreach (var error in errors.OrEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ internal static class MjmlRenderer

private static readonly IMjmlRenderer Renderer = new Mjml.Net.MjmlRenderer();

public static string FixXML(string mjml)
{
return Renderer.FixXML(mjml, OptionsStrict);
}

public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, bool strict, bool fix)
public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, bool strict)
{
if (string.IsNullOrWhiteSpace(mjml))
{
Expand All @@ -47,12 +42,10 @@ public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, b
{
try
{
var options = strict ? OptionsStrict : OptionsOptimized;

if (fix)
{
mjml = Renderer.FixXML(mjml, options);
}
var options =
strict ?
OptionsStrict :
OptionsOptimized;

(rendered, var mjmlErrors) = Renderer.Render(mjml, options);

Expand Down
12 changes: 9 additions & 3 deletions backend/src/Notifo.Domain/Log/Internal/LogCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ private async Task StoreAsync(
return;
}

commands = updateQueue.Select(x => (x.Key, x.Value, now)).ToList();
commands = new List<(LogWrite, int, Instant)>();

// Use a normal loop to avoid the allocations of the closure.
foreach (var (key, value) in updateQueue)
{
commands.Add((key, value, now));
}

updateQueue.Clear();
}
finally
{
updateQueue.Clear();

readerWriterLock.ExitWriteLock();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task EnhanceAsync(MetadataRequest request)
{
await using (var tempStream = tempFile.OpenWrite())
{
await assetThumbnailGenerator.FixOrientationAsync(uploadStream, mimeType, tempStream);
await assetThumbnailGenerator.FixAsync(uploadStream, mimeType, tempStream);
}
}

Expand Down
10 changes: 5 additions & 5 deletions backend/src/Notifo.Domain/Notifo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.5.2" />
<PackageReference Include="FluentValidation" Version="11.7.1" />
<PackageReference Include="Fluid.Core" Version="2.4.0" />
<PackageReference Include="Jint" Version="3.0.0-beta-2037" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.14" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="libphonenumber-csharp" Version="8.13.18" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Mjml.Net" Version="1.24.0" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="Mjml.Net" Version="2.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
Expand Down
8 changes: 4 additions & 4 deletions backend/src/Notifo.Identity/Notifo.Identity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="7.0.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="7.0.3" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="OpenIddict.AspNetCore" Version="4.5.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="4.7.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
Expand Down
36 changes: 18 additions & 18 deletions backend/src/Notifo.Infrastructure/Notifo.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.5.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="FluentValidation" Version="11.7.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -20,29 +20,29 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="7.0.8" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.0.0" />
<PackageReference Include="OpenTelemetry" Version="1.5.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="5.9.0" />
<PackageReference Include="Squidex.Assets.S3" Version="5.9.0" />
<PackageReference Include="Squidex.Caching" Version="5.9.0" />
<PackageReference Include="Squidex.Hosting" Version="5.9.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="5.9.0" />
<PackageReference Include="Squidex.Log" Version="5.9.0" />
<PackageReference Include="Squidex.Messaging" Version="5.9.0" />
<PackageReference Include="Squidex.Text" Version="5.9.0" />
<PackageReference Include="Squidex.Assets" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="5.16.0" />
<PackageReference Include="Squidex.Assets.S3" Version="5.16.0" />
<PackageReference Include="Squidex.Caching" Version="5.16.0" />
<PackageReference Include="Squidex.Hosting" Version="5.16.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="5.16.0" />
<PackageReference Include="Squidex.Log" Version="5.16.0" />
<PackageReference Include="Squidex.Messaging" Version="5.16.0" />
<PackageReference Include="Squidex.Text" Version="5.16.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="7.0.0" />
</ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions backend/src/Notifo/Notifo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
<ItemGroup>
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0-beta.3" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="4.0.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="7.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.7" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.9" />
<PackageReference Include="Namotion.Reflection" Version="2.1.2" />
<PackageReference Include="NSwag.AspNetCore" Version="13.19.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.5.1" />
Expand All @@ -30,7 +30,7 @@
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc8" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc8" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.All" Version="5.9.0" />
<PackageReference Include="Squidex.Messaging.All" Version="5.16.0" />
<PackageReference Include="Squidex.OpenTelemetry.Exporter.Stackdriver" Version="0.0.0-alpha.0.97" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.7" />
<PackageReference Include="FakeItEasy" Version="7.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
12 changes: 6 additions & 6 deletions backend/tests/Notifo.Domain.Tests/Notifo.Domain.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EphemeralMongo6" Version="1.1.0" />
<PackageReference Include="EphemeralMongo6" Version="1.1.2" />
<PackageReference Include="FakeItEasy" Version="7.4.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
<PackageReference Include="Verify.Xunit" Version="20.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Verify.Xunit" Version="20.7.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="7.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="7.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.62">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Verify.Xunit" Version="20.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Verify.Xunit" Version="20.7.0" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/pages/email-templates/EmailTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ export const EmailTemplate = (props: EmailTemplateProps) => {
<BodyText appId={appId} visible={!showHtml.value} />
</div>
</Form>
</FormProvider>

{updateDialog.value &&
<EmailTemplateMoreDialog onClose={updateDialog.off} />
}
{updateDialog.value &&
<EmailTemplateMoreDialog onClose={updateDialog.off} />
}
</FormProvider>
</>
) : (
<div className='empty-button'>
Expand Down

0 comments on commit 1c2e30e

Please sign in to comment.