Skip to content

Commit

Permalink
feat(mailing): adjust mail process creation
Browse files Browse the repository at this point in the history
Refs: CPLP-3383
  • Loading branch information
Phil91 committed Jan 17, 2024
1 parent cecfc06 commit 7460a31
Show file tree
Hide file tree
Showing 55 changed files with 770 additions and 564 deletions.
62 changes: 31 additions & 31 deletions src/Portal.Backend.sln
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.Seeding", "keycloa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.Seeding.Tests", "..\tests\keycloak\Keycloak.Seeding.Tests\Keycloak.Seeding.Tests.csproj", "{A5BEDD89-7280-466E-8D14-EC5E177AAD07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Service", "mailing\Mailing.Service\Mailing.Service.csproj", "{6113B579-C995-47F8-9AC1-4CC6EFDDD883}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Service.Tests", "..\tests\mailing\Mailing.Service.Tests\Mailing.Service.Tests.csproj", "{1EAF34DA-6D16-4F5E-86F4-344185F53942}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Executor", "processes\NetworkRegistration.Executor\NetworkRegistration.Executor.csproj", "{19639645-A115-4824-865F-5559DA8B892A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkRegistration.Library.Tests", "..\tests\processes\NetworkRegistration.Library.Tests\NetworkRegistration.Library.Tests.csproj", "{3B41408A-CDFE-4EEE-9660-FE6755FD2075}"
Expand All @@ -236,7 +232,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Registration.Common", "regi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Keycloak.Authentication.Tests", "..\tests\keycloak\Keycloak.Authentication.Tests\Keycloak.Authentication.Tests.csproj", "{C7ACF748-DEF4-4646-A791-F1DA437CC965}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Executer", "processes\Mailing.Executer\Mailing.Executer.csproj", "{D666EADA-770A-42FF-B891-5745F7A6BC2F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Executor", "processes\Mailing.Executor\Mailing.Executor.csproj", "{D666EADA-770A-42FF-B891-5745F7A6BC2F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Invitation.Executor", "processes\Invitation.Executor\Invitation.Executor.csproj", "{0551F0AF-5373-4516-87AA-01D7FFD29C0D}"
EndProject
Expand All @@ -250,6 +246,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Provisioning.Library", "ext
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalSystems.Provisioning.Library.Tests", "..\tests\externalsystems\ExternalSystems.Provisioning.Library.Tests\ExternalSystems.Provisioning.Library.Tests.csproj", "{B6A2A753-5876-4C6C-8CC2-151B022C87F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Library", "processes\Mailing.Library\Mailing.Library.csproj", "{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mailing.Library.Tests", "..\tests\processes\Mailing.Library.Tests\Mailing.Library.Tests.csproj", "{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1364,30 +1364,6 @@ Global
{A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x64.Build.0 = Release|Any CPU
{A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x86.ActiveCfg = Release|Any CPU
{A5BEDD89-7280-466E-8D14-EC5E177AAD07}.Release|x86.Build.0 = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|x64.ActiveCfg = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|x64.Build.0 = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|x86.ActiveCfg = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Debug|x86.Build.0 = Debug|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|Any CPU.Build.0 = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|x64.ActiveCfg = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|x64.Build.0 = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|x86.ActiveCfg = Release|Any CPU
{6113B579-C995-47F8-9AC1-4CC6EFDDD883}.Release|x86.Build.0 = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|x64.ActiveCfg = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|x64.Build.0 = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|x86.ActiveCfg = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Debug|x86.Build.0 = Debug|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|Any CPU.Build.0 = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x64.ActiveCfg = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x64.Build.0 = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x86.ActiveCfg = Release|Any CPU
{1EAF34DA-6D16-4F5E-86F4-344185F53942}.Release|x86.Build.0 = Release|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19639645-A115-4824-865F-5559DA8B892A}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1592,6 +1568,30 @@ Global
{B6A2A753-5876-4C6C-8CC2-151B022C87F7}.Release|x64.Build.0 = Release|Any CPU
{B6A2A753-5876-4C6C-8CC2-151B022C87F7}.Release|x86.ActiveCfg = Release|Any CPU
{B6A2A753-5876-4C6C-8CC2-151B022C87F7}.Release|x86.Build.0 = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|x64.ActiveCfg = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|x64.Build.0 = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|x86.ActiveCfg = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Debug|x86.Build.0 = Debug|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|Any CPU.Build.0 = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|x64.ActiveCfg = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|x64.Build.0 = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|x86.ActiveCfg = Release|Any CPU
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4}.Release|x86.Build.0 = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|x64.ActiveCfg = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|x64.Build.0 = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Debug|x86.Build.0 = Debug|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|Any CPU.Build.0 = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|x64.ActiveCfg = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|x64.Build.0 = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|x86.ActiveCfg = Release|Any CPU
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -1603,7 +1603,6 @@ Global
{996CAB8C-B43A-4E76-B906-034A395C1429} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{146865E5-7DFF-4CC2-8521-9E22CFCEEA20} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{A43B5ACA-1209-46E9-84DB-A48553ED623E} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{1EAF34DA-6D16-4F5E-86F4-344185F53942} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{A5BEDD89-7280-466E-8D14-EC5E177AAD07} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{EA9BA26E-83F6-47C4-BA3B-880AF1AD6A82} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{4B40193E-2C67-4DC4-8EF4-3286DAA01D8B} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
Expand Down Expand Up @@ -1696,7 +1695,6 @@ Global
{47E089E3-E875-4045-9E58-C1223BE899E9} = {23500169-FC01-4D2B-A997-E7FAE2169FC0}
{9D574E57-75A6-4965-AF23-ACE0BB9CD0B3} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{E1D41A07-F468-4D13-8185-35F127230B17} = {46383371-8252-4598-9350-A97692851408}
{6113B579-C995-47F8-9AC1-4CC6EFDDD883} = {68D43DB1-DFC5-4F15-A2B4-6BA18B875F9E}
{19639645-A115-4824-865F-5559DA8B892A} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{3B41408A-CDFE-4EEE-9660-FE6755FD2075} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{C53EAB34-1F66-48F8-88AB-226BE142D1CF} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
Expand All @@ -1711,5 +1709,7 @@ Global
{BF8EB6BB-E8CA-423C-AC50-01FB44D0D08B} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{16E69264-C872-41EB-9914-112416D1220C} = {C8957230-4203-452C-A085-34091C5E370B}
{B6A2A753-5876-4C6C-8CC2-151B022C87F7} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
{F2F9E057-668E-43BB-B3EB-10E8DE8E7BB4} = {282CEF03-292F-4A49-83C6-997567D0FF5F}
{07BDC20D-23DD-4C0E-9C3D-B1D232AF17E3} = {323C198D-A8C6-4EB0-8B79-72624275E35F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<ProjectReference Include="..\..\framework\Framework.Web\Framework.Web.csproj" />
<ProjectReference Include="..\..\mailing\Mailing.SendMail\Mailing.SendMail.csproj" />
<ProjectReference Include="..\..\notifications\Notifications.Library\Notifications.Library.csproj" />
<ProjectReference Include="..\..\processes\Mailing.Library\Mailing.Library.csproj" />
<ProjectReference Include="..\..\provisioning\Provisioning.Library\Provisioning.Library.csproj" />
<ProjectReference Include="..\..\portalbackend\PortalBackend.DBAccess\PortalBackend.DBAccess.csproj" />
<ProjectReference Include="..\..\processes\ApplicationChecklist.Config\ApplicationChecklist.Config.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using System.Globalization;
using System.Text.Json;

Expand All @@ -48,6 +49,7 @@ public class CompanyDataBusinessLogic : ICompanyDataBusinessLogic
private readonly ICustodianService _custodianService;
private readonly IDateTimeProvider _dateTimeProvider;
private readonly IIdentityData _identityData;
private readonly IMailingProcessCreation _mailingProcessCreation;
private readonly CompanyDataSettings _settings;

/// <summary>
Expand All @@ -57,13 +59,15 @@ public class CompanyDataBusinessLogic : ICompanyDataBusinessLogic
/// <param name="custodianService"></param>
/// <param name="dateTimeProvider"></param>
/// <param name="identityService"></param>
/// <param name="mailingProcessCreation"></param>
/// <param name="options"></param>
public CompanyDataBusinessLogic(IPortalRepositories portalRepositories, ICustodianService custodianService, IDateTimeProvider dateTimeProvider, IIdentityService identityService, IOptions<CompanyDataSettings> options)
public CompanyDataBusinessLogic(IPortalRepositories portalRepositories, ICustodianService custodianService, IDateTimeProvider dateTimeProvider, IIdentityService identityService, IMailingProcessCreation mailingProcessCreation, IOptions<CompanyDataSettings> options)
{
_portalRepositories = portalRepositories;
_custodianService = custodianService;
_dateTimeProvider = dateTimeProvider;
_identityData = identityService.IdentityData;
_mailingProcessCreation = mailingProcessCreation;
_settings = options.Value;
}

Expand Down Expand Up @@ -430,9 +434,6 @@ public async Task ApproveCredential(Guid credentialId, CancellationToken cancell

if (!string.IsNullOrWhiteSpace(data.RequesterData.RequesterEmail))
{
var processStepRepository = _portalRepositories.GetInstance<IProcessStepRepository>();
var processId = processStepRepository.CreateProcess(ProcessTypeId.MAILING).Id;
processStepRepository.CreateProcessStep(ProcessStepTypeId.SEND_MAIL, ProcessStepStatusId.TODO, processId);
var userName = string.Join(" ", new[] { data.RequesterData.Firstname, data.RequesterData.Lastname }.Where(item => !string.IsNullOrWhiteSpace(item)));
var mailParameters = new Dictionary<string, string>
{
Expand All @@ -442,8 +443,7 @@ public async Task ApproveCredential(Guid credentialId, CancellationToken cancell
{ "credentialType", typeValue },
{ "expiryDate", data.ExpiryDate == null ? string.Empty : data.ExpiryDate.Value.ToString("o", CultureInfo.InvariantCulture) }
};

_portalRepositories.GetInstance<IMailingInformationRepository>().CreateMailingInformation(processId, data.RequesterData.RequesterEmail, "CredentialApproval", mailParameters);
_mailingProcessCreation.CreateMailProcess(data.RequesterData.RequesterEmail, "CredentialApproval", mailParameters);
}
await _portalRepositories.SaveAsync().ConfigureAwait(false);
}
Expand Down Expand Up @@ -483,17 +483,13 @@ public async Task RejectCredential(Guid credentialId)

if (!string.IsNullOrWhiteSpace(requesterEmail))
{
var processStepRepository = _portalRepositories.GetInstance<IProcessStepRepository>();
var processId = processStepRepository.CreateProcess(ProcessTypeId.MAILING).Id;
processStepRepository.CreateProcessStep(ProcessStepTypeId.SEND_MAIL, ProcessStepStatusId.TODO, processId);
var userName = string.Join(" ", new[] { requesterFirstname, requesterLastname }.Where(item => !string.IsNullOrWhiteSpace(item)));
var mailParameters = new Dictionary<string, string>
{
{ "userName", !string.IsNullOrWhiteSpace(userName) ? userName : requesterEmail },
{ "requestName", typeValue }
};

_portalRepositories.GetInstance<IMailingInformationRepository>().CreateMailingInformation(processId, requesterEmail, "CredentialRejected", mailParameters);
_mailingProcessCreation.CreateMailProcess(requesterEmail, "CredentialRejected", mailParameters);
}
await _portalRepositories.SaveAsync().ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Processes.ApplicationChecklist.Library;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
Expand All @@ -50,6 +51,7 @@ public sealed class RegistrationBusinessLogic : IRegistrationBusinessLogic
private readonly IClearinghouseBusinessLogic _clearinghouseBusinessLogic;
private readonly ISdFactoryBusinessLogic _sdFactoryBusinessLogic;
private readonly IProvisioningManager _provisioningManager;
private readonly IMailingProcessCreation _mailingProcessCreation;
private readonly ILogger<RegistrationBusinessLogic> _logger;

public RegistrationBusinessLogic(
Expand All @@ -59,6 +61,7 @@ public RegistrationBusinessLogic(
IClearinghouseBusinessLogic clearinghouseBusinessLogic,
ISdFactoryBusinessLogic sdFactoryBusinessLogic,
IProvisioningManager provisioningManager,
IMailingProcessCreation mailingProcessCreation,
ILogger<RegistrationBusinessLogic> logger)
{
_portalRepositories = portalRepositories;
Expand All @@ -67,6 +70,7 @@ public RegistrationBusinessLogic(
_clearinghouseBusinessLogic = clearinghouseBusinessLogic;
_sdFactoryBusinessLogic = sdFactoryBusinessLogic;
_provisioningManager = provisioningManager;
_mailingProcessCreation = mailingProcessCreation;
_logger = logger;
}

Expand Down Expand Up @@ -505,18 +509,14 @@ private async Task PostRegistrationCancelEmailAsync(Guid applicationId, string c
throw new ConflictException($"user {userName} has no assigned email");
}

var processStepRepository = _portalRepositories.GetInstance<IProcessStepRepository>();
var processId = processStepRepository.CreateProcess(ProcessTypeId.MAILING).Id;
processStepRepository.CreateProcessStep(ProcessStepTypeId.SEND_MAIL, ProcessStepStatusId.TODO, processId);

var mailParameters = new Dictionary<string, string>
{
{ "userName", !string.IsNullOrWhiteSpace(userName) ? userName : user.Email },
{ "companyName", companyName },
{ "declineComment", comment},
{ "helpUrl", _settings.HelpAddress }
};
_portalRepositories.GetInstance<IMailingInformationRepository>().CreateMailingInformation(processId, user.Email, "EmailRegistrationDeclineTemplate", mailParameters);
_mailingProcessCreation.CreateMailProcess(user.Email, "EmailRegistrationDeclineTemplate", mailParameters);
}
}

Expand Down
Loading

0 comments on commit 7460a31

Please sign in to comment.