Skip to content

Commit 60ff082

Browse files
committed
RE1-T117 Fixing build
1 parent ec6cd04 commit 60ff082

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

Tests/Resgrid.Tests/Web/Services/TwilioControllerVoiceVerificationTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class TwilioControllerVoiceVerificationTests : TestBase
4545
private Mock<IEncryptionService> _encryptionServiceMock;
4646
private Mock<ITwilioVoiceResponseService> _twilioVoiceResponseServiceMock;
4747
private Mock<IChatbotIngressService> _chatbotIngressServiceMock;
48+
private Mock<IFeatureToggleService> _featureToggleServiceMock;
4849

4950
protected override void Before_all_tests()
5051
{
@@ -68,6 +69,7 @@ protected override void Before_all_tests()
6869
_communicationTestServiceMock = new Mock<ICommunicationTestService>();
6970
_encryptionServiceMock = new Mock<IEncryptionService>();
7071
_chatbotIngressServiceMock = new Mock<IChatbotIngressService>();
72+
_featureToggleServiceMock = new Mock<IFeatureToggleService>();
7173
_twilioVoiceResponseServiceMock = new Mock<ITwilioVoiceResponseService>();
7274
_departmentSettingsServiceMock.Setup(x => x.GetTtsLanguageForDepartmentAsync(It.IsAny<int>())).ReturnsAsync((string)null);
7375
_twilioVoiceResponseServiceMock
@@ -148,7 +150,8 @@ private TwilioController BuildController()
148150
_communicationTestServiceMock.Object,
149151
_encryptionServiceMock.Object,
150152
_twilioVoiceResponseServiceMock.Object,
151-
_chatbotIngressServiceMock.Object);
153+
_chatbotIngressServiceMock.Object,
154+
_featureToggleServiceMock.Object);
152155
}
153156

154157
private static string InvokeBuildDispatchPrompt(Type controllerType, Call call, string address)

Web/Resgrid.Web.Services/Controllers/TwilioController.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public async Task<ActionResult> IncomingMessage([FromQuery] TwilioMessage reques
153153
}
154154
}
155155

156+
// Carry the resolved department onto the inbound message event so chatbot-routed events
157+
// retain the same department context the text-command path records.
158+
if (departmentId.HasValue)
159+
messageEvent.CustomerId = departmentId.Value.ToString();
160+
156161
// Feature-flagged rollout: the chatbot ingress is the new path. When the flag is off
157162
// (globally or for this department) fall back to the original text-command handling so
158163
// existing behavior is preserved.
@@ -443,6 +448,14 @@ private async System.Threading.Tasks.Task ProcessTextCommandsAsync(TextMessage t
443448

444449
var call = await _callsService.GetCallByIdAsync(int.Parse(payload.Data));
445450

451+
// Guard against a missing call (NRE) and against reading a call that belongs
452+
// to another department (cross-department data leakage).
453+
if (call == null || call.DepartmentId != department.DepartmentId)
454+
{
455+
response.Message("Resgrid could not find that call.");
456+
break;
457+
}
458+
446459
var callText = new StringBuilder();
447460
callText.Append($"Call Information for {call.Name}" + Environment.NewLine);
448461
callText.Append("---------------------" + Environment.NewLine);
@@ -505,6 +518,13 @@ private async System.Threading.Tasks.Task ProcessTextCommandsAsync(TextMessage t
505518
break;
506519
case TextCommandTypes.Stop:
507520
messageEvent.Processed = true;
521+
522+
if (profile == null)
523+
{
524+
response.Message("Unable to locate your profile. Please log in to Resgrid to manage your text message settings.");
525+
break;
526+
}
527+
508528
await _userProfileService.DisableTextMessagesForUserAsync(profile.UserId);
509529
response.Message("Text messages are now turned off for this user, to enable again log in to Resgrid and update your profile.");
510530
break;

0 commit comments

Comments
 (0)