Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mjml #253

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.159">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<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.300.111" />
<PackageReference Include="Confluent.Kafka" Version="2.4.0" />
<PackageReference Include="Discord.Net" Version="3.15.2" />
<PackageReference Include="FirebaseAdmin" Version="3.0.0" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="Fluid.Core" Version="2.10.0" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.39" />
<PackageReference Include="AWSSDK.SimpleEmail" Version="3.7.401.11" />
<PackageReference Include="Confluent.Kafka" Version="2.5.3" />
<PackageReference Include="Discord.Net" Version="3.16.0" />
<PackageReference Include="FirebaseAdmin" Version="3.0.1" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Fluid.Core" Version="2.11.1" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.45" />
<PackageReference Include="Mailjet.Api" Version="3.0.0" />
<PackageReference Include="MailKit" Version="4.7.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="MailKit" Version="4.7.1.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="MongoDB.Driver" Version="2.27.0" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
<PackageReference Include="NodaTime" Version="3.1.12" />
<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="8.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
<PackageReference Include="Twilio" Version="7.2.1" />
<PackageReference Include="Twilio" Version="7.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ public ValueTask<EmailTemplate> CreateInitialAsync(
return new ValueTask<EmailTemplate>(template);
}

public ValueTask<EmailTemplate> ParseAsync(EmailTemplate input, bool strict,
public async ValueTask<EmailTemplate> ParseAsync(EmailTemplate input, bool strict,
CancellationToken ct = default)
{
var context = EmailContext.Create(PreviewData.Jobs, PreviewData.App, PreviewData.User, imageFormatter, emailUrl);

Format(input, context, true, strict);
await FormatAsync(input, context, true, strict);

if (context.Errors?.Count > 0)
{
throw new EmailFormattingException(context.Errors);
}

return new ValueTask<EmailTemplate>(input);
return input;
}

public ValueTask<FormattedEmail> FormatAsync(EmailTemplate input, IReadOnlyList<EmailJob> jobs, App app, User user, bool noCache = false,
public async ValueTask<FormattedEmail> FormatAsync(EmailTemplate input, IReadOnlyList<EmailJob> jobs, App app, User user, bool noCache = false,
CancellationToken ct = default)
{
var context = EmailContext.Create(jobs, app, user, imageFormatter, emailUrl);

var message = Format(input, context, noCache, false);
var message = await FormatAsync(input, context, noCache, false);

return new ValueTask<FormattedEmail>(new FormattedEmail(message, context.Errors));
return new FormattedEmail(message, context.Errors);
}

private static EmailMessage Format(EmailTemplate template, EmailContext context, bool noCache, bool strict)
private static async Task<EmailMessage> FormatAsync(EmailTemplate template, EmailContext context, bool noCache, bool strict)
{
var subject = string.Empty;

Expand All @@ -97,7 +97,7 @@ private static EmailMessage Format(EmailTemplate template, EmailContext context,

if (!string.IsNullOrWhiteSpace(template.BodyHtml))
{
bodyHtml = FormatBodyHtml(template.BodyHtml, context, noCache, strict)!;
bodyHtml = await FormatBodyHtmlAsync(template.BodyHtml, context, noCache, strict)!;
}

var firstJob = context.Jobs[0];
Expand Down Expand Up @@ -135,13 +135,13 @@ private static EmailMessage Format(EmailTemplate template, EmailContext context,
return result;
}

private static string? FormatBodyHtml(string template, EmailContext context, bool noCache, bool strict)
private static async Task<string?> FormatBodyHtmlAsync(string template, EmailContext context, bool noCache, bool strict)
{
var result = RenderTemplate(template, context, EmailTemplateType.BodyHtml, noCache);

context.ValidateTemplate(result, EmailTemplateType.BodyHtml);

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

foreach (var error in errors.OrEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ namespace Notifo.Domain.Channels.Email.Formatting;

internal static class MjmlRenderer
{
private static readonly MjmlOptions OptionsOptimized = new MjmlOptions
private static readonly MjmlOptions DefaultOptions = new MjmlOptions();

private static readonly MjmlOptions OptionsOptimized = DefaultOptions with
{
KeepComments = false,
};

private static readonly MjmlOptions OptionsStrict = new MjmlOptions
private static readonly MjmlOptions OptionsStrict = DefaultOptions with
{
Validator = StrictValidator.Instance,
};

private static readonly MjmlInternalRenderer Renderer = new MjmlInternalRenderer();
private static readonly IMjmlRenderer Renderer =
new MjmlInternalRenderer()
.AddHtmlAttributes()
.AddList();

public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, bool strict)
public static async ValueTask<(string? Html, List<TemplateError>? Errors)> RenderAsync(string? mjml, bool strict)
{
if (string.IsNullOrWhiteSpace(mjml))
{
Expand All @@ -48,7 +53,7 @@ public static (string? Html, List<TemplateError>? Errors) Render(string? mjml, b
OptionsStrict :
OptionsOptimized;

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

errors = mjmlErrors?.Select(x => new TemplateError(
x.Error,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Notifo.Domain/Integrations/ConditionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================

using Esprima.Ast;
using Acornima.Ast;
using Jint;
using Microsoft.Extensions.Caching.Memory;
using Options = Microsoft.Extensions.Options.Options;
Expand Down
17 changes: 9 additions & 8 deletions backend/src/Notifo.Domain/Notifo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="Fluid.Core" Version="2.10.0" />
<PackageReference Include="Jint" Version="3.1.4" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.39" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Fluid.Core" Version="2.11.1" />
<PackageReference Include="Jint" Version="4.0.2" />
<PackageReference Include="libphonenumber-csharp" Version="8.13.45" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Mjml.Net" Version="3.11.0" />
<PackageReference Include="MongoDB.Driver" Version="2.27.0" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="Mjml.Net" Version="4.1.0" />
<PackageReference Include="Mjml.Net.PostProcessors" Version="4.1.0" />
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
<PackageReference Include="NodaTime" Version="3.1.12" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
Expand Down
14 changes: 7 additions & 7 deletions backend/src/Notifo.Identity/Notifo.Identity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="8.1.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="8.2.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.6.2" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.7.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.1.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.0.2" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.8.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.8.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
</ItemGroup>
Expand Down
42 changes: 21 additions & 21 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.9.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -20,31 +20,31 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.27.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="MongoDB.Driver" Version="2.28.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.5.0" />
<PackageReference Include="NodaTime" Version="3.1.12" />
<PackageReference Include="NodaTime.Serialization.SystemTextJson" Version="1.2.0" />
<PackageReference Include="OpenTelemetry" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.S3" Version="6.12.0" />
<PackageReference Include="Squidex.Caching" Version="6.12.0" />
<PackageReference Include="Squidex.Hosting" Version="6.12.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.12.0" />
<PackageReference Include="Squidex.Log" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging" Version="6.12.0" />
<PackageReference Include="Squidex.Text" Version="6.12.0" />
<PackageReference Include="Squidex.Assets" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.19.0" />
<PackageReference Include="Squidex.Assets.S3" Version="6.19.0" />
<PackageReference Include="Squidex.Caching" Version="6.19.0" />
<PackageReference Include="Squidex.Hosting" Version="6.19.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.19.0" />
<PackageReference Include="Squidex.Log" Version="6.19.0" />
<PackageReference Include="Squidex.Messaging" Version="6.19.0" />
<PackageReference Include="Squidex.Text" Version="6.19.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="8.0.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions backend/src/Notifo/Notifo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
<ItemGroup>
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.2.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.5" />
<PackageReference Include="Namotion.Reflection" Version="3.1.1" />
<PackageReference Include="NSwag.AspNetCore" Version="14.0.8" />
<PackageReference Include="NSwag.AspNetCore" Version="14.1.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Messaging.All" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging.All" Version="6.19.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="8.0.3" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using Azure.Monitor.OpenTelemetry.Exporter;
using Google.Cloud.Diagnostics.Common;
using MongoDB.Driver.Core.Extensions.DiagnosticSources;
using Notifo;
using Notifo.Pipeline;
using OpenTelemetry.Resources;
Expand All @@ -33,7 +34,7 @@ public static void AddMyTelemetry(this IServiceCollection services, IConfigurati

builder.AddAspNetCoreInstrumentation();
builder.AddHttpClientInstrumentation();
builder.AddMongoDBInstrumentation();
builder.AddSource(typeof(DiagnosticsActivityEventSubscriber).Assembly.GetName().Name!);

var sampling = config.GetValue<double>("logging:otlp:sampling");

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.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="FakeItEasy" Version="8.3.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163">
<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 @@ -684,7 +684,9 @@
},
mj-style: {
Attributes: {
inline: null
inline: [
inline
]
}
},
mj-table: {
Expand Down Expand Up @@ -1483,7 +1485,9 @@
},
mj-style: {
Attributes: {
inline: null
inline: [
inline
]
}
},
mj-table: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@
},
"mj-style": {
"attrs": {
"inline": null
"inline": [
"inline"
]
},
"children": null
},
Expand Down
Loading