Skip to content

Commit 977553e

Browse files
author
gauffininteractive
committed
Can now notify users properly when closing an incident
1 parent 73c6bc3 commit 977553e

File tree

7 files changed

+32
-12
lines changed

7 files changed

+32
-12
lines changed

src/Server/OneTrueError.Api/Core/Messaging/EmailMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public EmailMessage()
2828
/// <param name="recipient">Destination</param>
2929
public EmailMessage(string recipient)
3030
{
31-
if (recipient == null) throw new ArgumentNullException(nameof(recipient));
31+
if (recipient == null) throw new ArgumentNullException("recipient");
3232
Recipients = new[] {new EmailAddress(recipient)};
3333
Resources = new List<EmailResource>();
3434
}
@@ -39,7 +39,7 @@ public EmailMessage(string recipient)
3939
/// <param name="recipients">List of recipients</param>
4040
public EmailMessage(IReadOnlyList<string> recipients)
4141
{
42-
if (recipients == null) throw new ArgumentNullException(nameof(recipients));
42+
if (recipients == null) throw new ArgumentNullException("recipients");
4343
if (recipients.Count == 0) throw new ArgumentException("Tried to send to an empty list.", "recipients");
4444

4545
Recipients = recipients.Select(x => new EmailAddress(x)).ToArray();

src/Server/OneTrueError.SqlServer/Core/Feedback/FeedbackRepository.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Griffin.Data;
55
using Griffin.Data.Mapper;
66
using OneTrueError.App.Core.Feedback;
7-
using OneTrueError.SqlServer.Tools;
87

98
namespace OneTrueError.SqlServer.Core.Feedback
109
{
@@ -31,8 +30,21 @@ public async Task UpdateAsync(FeedbackEntity feedback)
3130
public async Task<IReadOnlyList<string>> GetEmailAddressesAsync(int incidentId)
3231
{
3332
var emailAddresses = new List<string>();
34-
var items = await _unitOfWork.ToListAsync<string>("FROM Incidents WHERE Id = ?", incidentId);
35-
return items;
33+
using (var cmd = _unitOfWork.CreateDbCommand())
34+
{
35+
cmd.CommandText =
36+
"SELECT distinct EmailAddress FROM IncidentFeedback WHERE IncidentId = @id AND EmailAddress IS NOT NULL";
37+
cmd.AddParameter("id", incidentId);
38+
using (var reader = await cmd.ExecuteReaderAsync())
39+
{
40+
while (await reader.ReadAsync())
41+
{
42+
emailAddresses.Add(reader.GetString(0));
43+
}
44+
}
45+
}
46+
47+
return emailAddresses;
3648
}
3749
}
3850
}

src/Server/OneTrueError.Web/ViewModels/Incident/CloseViewModel.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Server/OneTrueError.Web/ViewModels/Incident/CloseViewModel.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Server/OneTrueError.Web/ViewModels/Incident/CloseViewModel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ module OneTrueError.Incident {
6060

6161
var closeCmd = new CloseIncident(solution.value, this.incidentId);
6262

63-
var sendMessage = <HTMLInputElement>this.context.select.one('[name="sendCustomerMessage"]');
63+
var sendMessage = <HTMLInputElement>this.context.select.one('sendCustomerMessage');
64+
console.log(sendMessage);
6465
if (sendMessage.checked) {
6566
var subject = (<HTMLInputElement>this.context.select.one('[name="UserSubject"]'));
6667
var text = (<HTMLInputElement>this.context.select.one('[name="UserText"]'));
6768
if (subject.value.length === 0 || text.value.length === 0) {
6869
alert("You specified that you wanted to send a notification to your users, but you have not specified subject or body of the message.");
6970
return;
7071
}
72+
closeCmd.NotificationText = text.value;
73+
closeCmd.CanSendNotification = true;
74+
closeCmd.NotificationTitle = subject.value;
7175
}
7276

7377
CqsClient.command(closeCmd);

src/Server/OneTrueError.Web/Views/Incident/Close.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h2>Customer message</h2>
7979
</p>
8080
<div id="status-panel" style="display: none">
8181
<p>
82-
This text will go out to all users that have subscribed on status updates for this error. (Currently <span data-name="SubscriberCount">0</span> people).
82+
This text will go out to all users that have subscribed on status updates for this error. (Currently <span data-name="WaitingUserCount">0</span> people).
8383
</p>
8484
<p>
8585
The text typically informs them about that the error is corrected and will be pushed out in the next release.

src/Server/OneTrueError.Web/Views/Incident/incident.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 data-name="Description" style="display: inline"></h1>
2626
</p>
2727
<div data-if="vm.IsIgnored">
2828
<em>
29-
Incident is ignored, i.e. no notifcations will be sent for this incident. New reports are thrown away (but the counter will increase to
29+
Incident is ignored, i.e. no notifications will be sent for this incident. New reports are thrown away (but the counter will increase to
3030
indicate that it's still active).
3131
</em>
3232
</div>
@@ -69,13 +69,13 @@ <h1 data-name="ReportCount"></h1>
6969
</a>
7070
</div>
7171
<div class="tile-nephritis tile tile-medium">
72-
<a href="/incident/:incidentId/users">
72+
<a href="#/application/:applicationId/incident/:incidentId/users">
7373
<h4 title="Number of users waiting for a fix">Users waiting</h4>
7474
<h1 data-name="WaitingUserCount"></h1>
7575
</a>
7676
</div>
7777
<div class="tile-nephritis tile tile-medium">
78-
<a href="/incident/:incidentId/feedback">
78+
<a href="#/application/:applicationId/incident/:incidentId/feedback">
7979
<h4 title="Number of users waiting for a fix">Feedback count</h4>
8080
<h1 data-name="FeedbackCount"></h1>
8181
</a>

0 commit comments

Comments
 (0)