Skip to content

Commit

Permalink
Incluindo o link para se desinscrever no email promocional de novo li…
Browse files Browse the repository at this point in the history
…vro.
  • Loading branch information
Raffaello Damgaard committed Dec 25, 2024
1 parent c1dea07 commit 075318c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,11 @@ <h3 style="text-align: center;display: block;margin: 0;padding: 0;color: #444444
<td valign="top" class="mcnTextContent" style="padding-top: 0;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #FFFFFF;font-family: Helvetica;font-size: 12px;line-height: 150%;text-align: center;">

<em>
Copyleft © 2023 Sharebook, All rights open source.
Copyleft © 2025 Sharebook, All rights open source.
</em>
<br>

<hr>
Não deseja mais receber esse tipo de email? Tudo bem, use esse <a href="{SharebookBaseUrl}/api/Account/unsubscribe?unsubToken={UnsubToken}" target="_blank">link para se desisncrever</a>.


</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ private async Task<string> GetEmailTemplateAsync(Guid bookId){
BookSlug = book.Slug,
BookImageSlug = book.ImageSlug,
SharebookBaseUrl = _configuration["ServerSettings:DefaultUrl"],
Name = "{Name}"// o MailSender vai trocar pelo nome do usuário.
Name = "{Name}", // o MailSender vai trocar pelo nome do usuário.
UnsubToken = "{UnsubToken}", // o MailSender vai trocar pelo unsub token.
};

return await _emailTemplate.GenerateHtmlFromTemplateAsync("NewBookNotifyTemplate", vm);
Expand Down
17 changes: 12 additions & 5 deletions ShareBook/Sharebook.Jobs/Jobs/7 - MailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public class MailSender : GenericJob, IJob
private readonly MailSenderLowPriorityQueue _sqsLowPriority;
private readonly IConfiguration _configuration;
private string _lastQueue;
private IList<string> _log;
private IList<string> _log;
private readonly IUserService _userService;

public MailSender(
IJobHistoryRepository jobHistoryRepo,
IEmailService emailService,
MailSenderLowPriorityQueue sqsLowPriority,
MailSenderHighPriorityQueue sqsHighPriority,
IConfiguration configuration) : base(jobHistoryRepo)
IConfiguration configuration,
IUserService userService) : base(jobHistoryRepo)
{

JobName = "MailSender";
Expand All @@ -43,7 +45,8 @@ public MailSender(
_sqsLowPriority = sqsLowPriority;
_sqsHighPriority = sqsHighPriority;
_configuration = configuration;
_log = new List<string>();
_log = new List<string>();
_userService = userService;
}

public override async Task<JobHistory> WorkAsync()
Expand Down Expand Up @@ -96,13 +99,17 @@ private async Task<int> SendEmailAsync(SharebookMessage<MailSenderbody> sqsMessa
}

string firstName = GetFirstName(destination.Name);
var bodyHtml2 = bodyHtml.Replace("{name}", firstName, StringComparison.OrdinalIgnoreCase);
var bodyHtml2 = bodyHtml.Replace("{name}", firstName, StringComparison.OrdinalIgnoreCase);

var unsubToken = await _userService.GenerateUnsubscriptionToken(destination.Email);
bodyHtml2 = bodyHtml.Replace("{unsubToken}", unsubToken, StringComparison.OrdinalIgnoreCase);

await _emailService.SendSmtpAsync(destination.Email, destination.Name, bodyHtml2, subject, copyAdmins);

_log.Add($"Enviei um email com SUCESSO para {destination.Email}.");
}
catch(Exception ex) {
RollbarLocator.RollbarInstance.Error(ex);
RollbarLocator.RollbarInstance.Error(ex); // deveria estar abstraído no uso do illoger
_log.Add($"Ocorreu um ERRO ao enviar email para {destination.Email}. Erro: {ex.Message}");
}

Expand Down

0 comments on commit 075318c

Please sign in to comment.