diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/UnsubscribeNotificationTest/WhenUnsubscribingFromNotification.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/UnsubscribeNotificationTest/WhenUnsubscribingFromNotification.cs index 226121da57..cb75120f73 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/UnsubscribeNotificationTest/WhenUnsubscribingFromNotification.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Commands/UnsubscribeNotificationTest/WhenUnsubscribingFromNotification.cs @@ -133,22 +133,5 @@ public async Task ShouldUnsubscribeFromOneAccount() var setting = list.SingleOrDefault(m => m.AccountId == _command.AccountId); setting.ReceiveNotifications.Should().BeFalse(); } - - [Test] - public async Task ShouldSendEmail() - { - Email mask = null; - _command.NotificationSettingUrl = "this/is/url"; - _notiApi.Setup(n => n.SendEmail(It.IsAny())) - .Callback(m => mask = m) - .Returns(Task.FromResult(1)); - - await _sut.Handle(_command); - mask.RecipientsAddress.Should().Be("email@email.com"); - mask.Subject.Should().Be("UnsubscribeSuccessful"); - mask.Tokens["name"].Should().Be("First name"); - mask.Tokens["account_name"].Should().Be("Account Name"); - mask.Tokens["link_notification_page"].Should().Be(_command.NotificationSettingUrl); - } } } diff --git a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/UserSettingsOrchestrator.cs b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/UserSettingsOrchestrator.cs index 7f6b02dcd3..2e550cd149 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/UserSettingsOrchestrator.cs +++ b/src/SFA.DAS.EmployerAccounts.Web/Orchestrators/UserSettingsOrchestrator.cs @@ -93,8 +93,7 @@ await _mediator.SendAsync( new UnsubscribeNotificationCommand { UserRef = userRef, - AccountId = accountId, - NotificationSettingUrl = settingUrl + AccountId = accountId }); _logger.Info("Unsubscribed from alerts for user {userRef} in account {accountId}"); diff --git a/src/SFA.DAS.EmployerAccounts.Web/Views/Settings/NotificationUnsubscribe.cshtml b/src/SFA.DAS.EmployerAccounts.Web/Views/Settings/NotificationUnsubscribe.cshtml index c33c08688b..4cd74030b3 100644 --- a/src/SFA.DAS.EmployerAccounts.Web/Views/Settings/NotificationUnsubscribe.cshtml +++ b/src/SFA.DAS.EmployerAccounts.Web/Views/Settings/NotificationUnsubscribe.cshtml @@ -13,21 +13,19 @@ {

You've already unsubscribed

-

You've already unsubscribed from notifications for @Model.Data.AccountName

+

You've already unsubscribed from notifications for @{@Model.Data.AccountName}.

-

You'll continue to receive important service email, such as password resets.

- } - else - { +

You'll continue to receive important service emails, such as password resets.

+ } + else + {

Unsubscribe successful

-

You've unsubscribed from any further email notification for @Model.Data.AccountName

- -

You'll receive one final email to confirm that we've unsubscribed you.

+

You've unsubscribed from any further email notifications for @{@Model.Data.AccountName}.

-

You'll continue to receive important service email, such as password resets.

+

You'll continue to receive important service emails, such as password resets.

} @Html.ActionLink("View notification settings","NotificationSettings", null, new { @class = "button" }) - \ No newline at end of file + diff --git a/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationCommand.cs b/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationCommand.cs index 59a842f928..a7204bcbe2 100644 --- a/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationCommand.cs +++ b/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationCommand.cs @@ -7,7 +7,5 @@ public class UnsubscribeNotificationCommand : IAsyncRequest public string UserRef { get; set; } public long AccountId { get; set; } - - public string NotificationSettingUrl { get; set; } } } diff --git a/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationHandler.cs b/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationHandler.cs index a2114ffe7f..a6ea7857a5 100644 --- a/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Commands/UnsubscribeNotification/UnsubscribeNotificationHandler.cs @@ -48,38 +48,6 @@ protected override async Task HandleCore(UnsubscribeNotificationCommand command) setting.ReceiveNotifications = false; await _accountRepository.UpdateUserAccountSettings(command.UserRef, settings); - - try - { - var user = _userRepository.GetUserByRef(command.UserRef); - await Task.WhenAll(user); - _logger.Info($"Sending email to unsubscriber: {user.Result.Id}"); - var email = CreateEmail(user.Result, setting.Name, command.NotificationSettingUrl); - await _notificationsApi.SendEmail(email); - } - catch (Exception ex) - { - _logger.Error(ex, "Error sending email to notifications api"); - throw; - } - } - - private Email CreateEmail(User user, string accountName, string notificationSettingUrl) - { - return new Email - { - RecipientsAddress = user.Email, - TemplateId = "EmployerUnsubscribeAlertSummaryNotification", - ReplyToAddress = "noreply@sfa.gov.uk", - Subject = "UnsubscribeSuccessful", - SystemId = "x", - Tokens = new Dictionary - { - { "name", user.FirstName }, - { "account_name", accountName }, - { "link_notification_page", notificationSettingUrl ?? string.Empty } - } - }; } } } \ No newline at end of file