feat(templates): add localized push templates and actions

Share template keys across email and push with independent editors and revisions. Render localized actions and preserve version-one delivery.

Ref: IT-1627
This commit is contained in:
2026-10-31 09:38:05 +02:00
parent d4ee8fc0c8
commit aba4173827
79 changed files with 3906 additions and 104 deletions
@@ -17,6 +17,9 @@ internal sealed class EmailTemplateDefinitionEntityConfiguration : IEntityTypeCo
builder.HasIndex(x => new { x.ServiceId, x.Key }).IsUnique();
builder.HasAlternateKey(x => new { x.Id, x.ServiceId });
builder.HasOne(x => x.Service).WithMany().HasForeignKey(x => x.ServiceId).OnDelete(DeleteBehavior.Restrict);
builder.HasOne(x => x.Template).WithOne(x => x.Email)
.HasForeignKey<EmailTemplateDefinitionEntity>(x => new { x.ServiceId, x.Key })
.HasPrincipalKey<TemplateEntity>(x => new { x.ServiceId, x.Key }).OnDelete(DeleteBehavior.Cascade);
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
builder.OwnsMany(x => x.Variables, v =>
@@ -0,0 +1,31 @@
using HrynCo.NotificationService.DAL.EF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HrynCo.NotificationService.DAL.EF.Configurations;
internal sealed class PushTemplateDefinitionEntityConfiguration : IEntityTypeConfiguration<PushTemplateDefinitionEntity>
{
public void Configure(EntityTypeBuilder<PushTemplateDefinitionEntity> builder)
{
builder.ToTable("push_template_definitions");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("id");
builder.Property(x => x.ServiceId).HasColumnName("service_id");
builder.Property(x => x.Key).HasColumnName("key").HasMaxLength(100).IsRequired();
builder.Property(x => x.Revision).HasColumnName("revision").IsConcurrencyToken();
builder.HasIndex(x => new { x.ServiceId, x.Key }).IsUnique();
builder.HasAlternateKey(x => new { x.Id, x.ServiceId });
builder.HasOne(x => x.Template).WithOne(x => x.Push)
.HasForeignKey<PushTemplateDefinitionEntity>(x => new { x.ServiceId, x.Key })
.HasPrincipalKey<TemplateEntity>(x => new { x.ServiceId, x.Key }).OnDelete(DeleteBehavior.Cascade);
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
builder.OwnsMany(x => x.Variables, v =>
{
v.ToJson("variables");
v.Property(x => x.Name).HasJsonPropertyName("name");
v.Property(x => x.Required).HasJsonPropertyName("required");
});
}
}
@@ -0,0 +1,30 @@
using HrynCo.NotificationService.DAL.EF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HrynCo.NotificationService.DAL.EF.Configurations;
internal sealed class PushTemplateEntityConfiguration : IEntityTypeConfiguration<PushTemplateEntity>
{
public void Configure(EntityTypeBuilder<PushTemplateEntity> builder)
{
builder.ToTable("push_templates");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("id");
builder.Property(x => x.DefinitionId).HasColumnName("definition_id");
builder.Property(x => x.ServiceId).HasColumnName("service_id");
builder.Property(x => x.ServiceLanguageId).HasColumnName("service_language_id");
builder.HasIndex(x => new { x.DefinitionId, x.ServiceLanguageId }).IsUnique();
builder.HasOne(x => x.Definition).WithMany(x => x.Languages)
.HasForeignKey(x => new { x.DefinitionId, x.ServiceId })
.HasPrincipalKey(x => new { x.Id, x.ServiceId }).OnDelete(DeleteBehavior.Cascade);
builder.HasOne(x => x.ServiceLanguage).WithMany()
.HasForeignKey(x => new { x.ServiceLanguageId, x.ServiceId })
.HasPrincipalKey(x => new { x.Id, x.ServiceId }).OnDelete(DeleteBehavior.Restrict);
builder.Property(x => x.Title).HasColumnName("title").IsRequired();
builder.Property(x => x.Body).HasColumnName("body").IsRequired();
builder.Property(x => x.ActionsJson).HasColumnName("actions").HasColumnType("jsonb").IsRequired();
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
}
}
@@ -0,0 +1,21 @@
using HrynCo.NotificationService.DAL.EF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HrynCo.NotificationService.DAL.EF.Configurations;
internal sealed class TemplateEntityConfiguration : IEntityTypeConfiguration<TemplateEntity>
{
public void Configure(EntityTypeBuilder<TemplateEntity> builder)
{
builder.ToTable("templates");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("id");
builder.Property(x => x.ServiceId).HasColumnName("service_id");
builder.Property(x => x.Key).HasColumnName("key").HasMaxLength(100).IsRequired();
builder.HasAlternateKey(x => new { x.ServiceId, x.Key });
builder.HasOne(x => x.Service).WithMany().HasForeignKey(x => x.ServiceId).OnDelete(DeleteBehavior.Restrict);
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
}
}