Skip to content

Commit

Permalink
Merge pull request #459 from Laixer/feature/email-update
Browse files Browse the repository at this point in the history
Feature/email update
  • Loading branch information
yorickdewid authored Feb 5, 2021
2 parents 6a2f4eb + 91f744a commit 5f39add
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 73 deletions.
7 changes: 5 additions & 2 deletions src/FunderMaps.Core/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public User()
/// Print object as name.
/// </summary>
/// <returns>String representing user.</returns>
public override string ToString() => Email;
public override string ToString()
=> !string.IsNullOrEmpty(GivenName)
? (!string.IsNullOrEmpty(LastName) ? $"{GivenName} {LastName}" : GivenName)
: Email;

/// <summary>
/// Initialize property defaults.
Expand All @@ -81,7 +84,7 @@ public override void InitializeDefaults()
/// </summary>
public override void InitializeDefaults(User other)
{
if (other == null)
if (other is null)
{
throw new ArgumentNullException(nameof(other));
}
Expand Down
23 changes: 16 additions & 7 deletions src/FunderMaps.Core/IncidentReport/IncidentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace FunderMaps.Core.IncidentReport
internal class IncidentService : IIncidentService // TODO: inherit from AppServiceBase
{
private readonly IncidentOptions _options;
private readonly Core.AppContext _appContext;
private readonly IContactRepository _contactRepository;
private readonly IIncidentRepository _incidentRepository;
private readonly IGeocoderTranslation _geocoderTranslation;
Expand All @@ -28,14 +27,12 @@ internal class IncidentService : IIncidentService // TODO: inherit from AppServi
/// </summary>
public IncidentService(
IOptions<IncidentOptions> options,
Core.AppContext appContext,
IContactRepository contactRepository,
IIncidentRepository incidentRepository,
IGeocoderTranslation geocoderTranslation,
INotifyService notificationService)
{
_options = options?.Value ?? throw new ArgumentNullException(nameof(options));
_appContext = appContext ?? throw new ArgumentNullException(nameof(appContext));
_contactRepository = contactRepository ?? throw new ArgumentNullException(nameof(contactRepository));
_incidentRepository = incidentRepository ?? throw new ArgumentNullException(nameof(incidentRepository));
_geocoderTranslation = geocoderTranslation ?? throw new ArgumentNullException(nameof(geocoderTranslation));
Expand Down Expand Up @@ -149,16 +146,28 @@ public async Task<Incident> AddAsync(Incident incident, object meta = null)
List<string> recipients = new(_options.Recipients);
recipients.Add(incident.Email);

await _notifyService.DispatchNotifyAsync(new()
string subject = $"Nieuwe melding: {incident.Id}";

object header = new
{
Title = subject,
Preheader = "Dit is een kopie van de door u verzonden melding in het funderingsloket."
};

string footer = "Dit bericht wordt verstuurd wanneer een melding binnenkomt op het loket.";

await _notifyService.NotifyAsync(new()
{
Recipients = recipients,
Subject = $"Nieuwe melding: {incident.Id}",
Template = "incident",
Subject = subject,
Template = "Incident",
Items = new Dictionary<string, object>
{
{ "header", header },
{ "footer", footer },
{ "incident", incident },
{ "address", address },
{ "contact", incident.ContactNavigation }
{ "contact", incident.ContactNavigation },
},
Extensions = new List<object> { new TranslationFunctions() },
});
Expand Down
2 changes: 1 addition & 1 deletion src/FunderMaps.Core/Notification/INotifyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface INotifyService
/// Notify by means of contacting.
/// </summary>
/// <param name="envelope">Envelope containing the notification.</param>
Task DispatchNotifyAsync(Envelope envelope);
Task NotifyAsync(Envelope envelope);
}
}
2 changes: 1 addition & 1 deletion src/FunderMaps.Core/Notification/NotificationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public NotificationHub(AppContext appContext, BackgroundTaskScopedDispatcher bac
/// Notify by means of contacting.
/// </summary>
/// <param name="envelope">Envelope containing the notification.</param>
public async Task DispatchNotifyAsync(Envelope envelope)
public async Task NotifyAsync(Envelope envelope)
=> await _backgroundTaskDispatcher.EnqueueTaskAsync(TaskName, envelope);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/FunderMaps.Core/Template/Email/Footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
<tr>
<td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; font-size: 12px; color: #999999; text-align: center;">
<span class="apple-link" style="color: #999999; font-size: 12px; text-align: center;">Dit bericht wordt verstuurd wanneer een melding binnenkomt op het loket.</span>
<span class="apple-link" style="color: #999999; font-size: 12px; text-align: center;">{{ footer }}</span>
</td>
</tr>
</table>
Expand Down
20 changes: 10 additions & 10 deletions src/FunderMaps.Core/Template/Email/Header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Simple Transactional Email</title>
<title>{{ header.title }}</title>
<style>
/* -------------------------------------
INLINED WITH htmlemail.io/inline
Expand Down Expand Up @@ -69,14 +69,14 @@
width: 100%;
}

.ExternalClass,
.ExternalClass p,
.ExternalClass span,
.ExternalClass font,
.ExternalClass td,
.ExternalClass div {
line-height: 100%;
}
.ExternalClass,
.ExternalClass p,
.ExternalClass span,
.ExternalClass font,
.ExternalClass td,
.ExternalClass div {
line-height: 100%;
}

.apple-link a {
color: inherit !important;
Expand Down Expand Up @@ -108,7 +108,7 @@
</style>
</head>
<body class="" style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">This is preheader text. Some clients will show this text as a preview.</span>
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">{{ header.preheader }}</span>
<table border="0" cellpadding="0" cellspacing="0" class="body" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: #f6f6f6;">
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">&nbsp;</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">
<p style="font-family: sans-serif; font-size: 22px; font-weight: bold; margin: 0;">Loket melding</p>
<p style="font-family: sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{{ incident.id }}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Er is een nieuwe melding binnen gekomen voor <b>{{ address.full_address }}</b></p>
{% if incident.email %}
<p style="font-family: sans-serif; font-size: 22px; font-weight: bold; margin: 0;">Funderingsloket melding</p>
<p style="font-family: sans-serif; font-size: 12px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Meldingnummer: {{ incident.id }}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Dit is een kopie van de door u verzonden melding in het funderingsloket.</b></p>
<hr>
<h3>Contactgegevens:</h3>
<h3>Melding gegevens</h3>
<table style="margin-bottom: 1em;">
<tr>
<td>Adres</td>
<td>{{ address.full_address }}</td>
</tr>
<tr>
<td>Naam</td>
<td>{{ contact.name }}</td>
Expand All @@ -24,7 +27,6 @@ <h3>Contactgegevens:</h3>
<td>{{ contact.email }}</td>
</tr>
</table>
{% endif %}
<hr>
<h3>Melding informatie</h3>
<table style="margin-bottom: 1em;">
Expand Down
14 changes: 14 additions & 0 deletions src/FunderMaps.Core/Template/Email/InquiryApproved.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- START MAIN CONTENT AREA -->
<tr>
<td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">
<p style="font-family: sans-serif; font-size: 22px; font-weight: bold; margin: 0; Margin-bottom: 15px;">FunderMaps | {{ organization }}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{{ reviewer }} heeft document '{{ inquiry.document_name }}' gereviewd en goedgekeurd.</p>
</td>
</tr>
</table>
</td>
</tr>
<!-- END MAIN CONTENT AREA -->
20 changes: 20 additions & 0 deletions src/FunderMaps.Core/Template/Email/InquiryRejected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- START MAIN CONTENT AREA -->
<tr>
<td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">
<p style="font-family: sans-serif; font-size: 22px; font-weight: bold; margin: 0; Margin-bottom: 15px;">FunderMaps | {{ organization }}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{{ reviewer }} heeft document '{{ inquiry.document_name }}' gereviewd en afgekeurd met de volgende reden:</p>
<hr>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">{{ message }}</p>
<hr />
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Het document is vrijgegeven voor aanpassingen. Verwerk de opmerkingen en biedt opnieuw aan ter review.</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;"><a href="{{ redirect_link }}">Klik hier om direct naar het document te gaan.</a></p>

</td>
</tr>
</table>
</td>
</tr>
<!-- END MAIN CONTENT AREA -->
15 changes: 15 additions & 0 deletions src/FunderMaps.Core/Template/Email/InquiryReview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- START MAIN CONTENT AREA -->
<tr>
<td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
<tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">
<p style="font-family: sans-serif; font-size: 22px; font-weight: bold;margin: 0; Margin-bottom: 15px;">FunderMaps | {{ organization }}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{{ creator }} heeft document '{{ inquiry.document_name }}' verwerkt en ter review aangeboden.</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;"><a href="{{ redirect_link }}">Klik hier om direct naar het document te gaan.</a></p>
</td>
</tr>
</table>
</td>
</tr>
<!-- END MAIN CONTENT AREA -->
Loading

0 comments on commit 5f39add

Please sign in to comment.