Skip to content

Commit

Permalink
invalid number handling #971 (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman authored May 4, 2024
1 parent 722476c commit 4006b4a
Show file tree
Hide file tree
Showing 6 changed files with 2,084 additions and 1,406 deletions.
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release Notes

### 4.3.4 (UNRELEASED)
* Fix for dialback dialing [#1021]
* Fix for dialback dialing. [#1021]
* Fix for when an invalid or out of service number is specified for a volunteer. [#971]

### 4.3.3 (May 1, 2024)
* Fix for reports where they are always recursing service bodies regardless of the setting [#980]
Expand Down
3 changes: 3 additions & 0 deletions src/app/Constants/EventId.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class EventId
const SPAD_LOOKUP = 23;
const SPAD_LOOKUP_SMS = 24;
const VOLUNTEER_SEARCH_FORCE_DIALED = 25;
const VOLUNTEER_NUMBER_BAD = 26;

public static function getEventById($id)
{
Expand Down Expand Up @@ -82,6 +83,8 @@ public static function getEventById($id)
return "SPAD Lookup via SMS";
case self::VOLUNTEER_SEARCH_FORCE_DIALED:
return "Volunteer Search Force Dial";
case self::VOLUNTEER_NUMBER_BAD:
return "Volunteer Number is Bad";
}
}
}
15 changes: 12 additions & 3 deletions src/app/Http/Controllers/HelplineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ public function search(Request $request)
public function dial(Request $request)
{
if ($request->has('noop')) {
if ($request->has('CallStatus') && $request->get('CallStatus') == TwilioCallStatus::NOANSWER) {
if ($request->has('CallStatus') &&
($request->get('CallStatus') == TwilioCallStatus::NOANSWER || $request->get('CallStatus') == TwilioCallStatus::FAILED)) {
$this->twilio->incrementNoAnswerCount();
}

Expand Down Expand Up @@ -298,9 +299,9 @@ public function dial(Request $request)
}
}

// Make timeout configurable per volunteer
// TODO: Make timeout configurable per volunteer
if (( $request->has('SequenceNumber') && intval($request->get('SequenceNumber')) == 1 ) ||
( $request->has('CallStatus') && ($request->get('CallStatus') == TwilioCallStatus::NOANSWER || $request->get('CallStatus') == TwilioCallStatus::COMPLETED ))) {
( $request->has('CallStatus') && ($request->get('CallStatus') == TwilioCallStatus::NOANSWER || $request->get('CallStatus') == TwilioCallStatus::COMPLETED || $request->get('CallStatus') == TwilioCallStatus::FAILED ))) {
$callConfig = $this->getCallConfig($request, $serviceBodyCallHandling);

if ($request->has('CallStatus') && $request->get('CallStatus') == TwilioCallStatus::NOANSWER) {
Expand All @@ -310,6 +311,14 @@ public function dial(Request $request)
$request->get('CallSid'),
CallRole::VOLUNTEER
);
} else if ($request->has('CallStatus') && $request->get('CallStatus') == TwilioCallStatus::FAILED) {
Log::error(sprintf("Volunteer Call Failed %s: %s", $request->get('Called'), $request->get('ErrorMessage')));
$this->call->insertCallEventRecord(EventId::VOLUNTEER_NUMBER_BAD, (object)['to_number' => $request->get('Called'), 'error' => $request->get('ErrorMessage')]);
$this->call->setConferenceParticipant(
$request->get('FriendlyName'),
$request->get('CallSid'),
CallRole::VOLUNTEER
);
}

Log::debug("Next volunteer to call " . $callConfig->volunteer->phoneNumber);
Expand Down
13 changes: 13 additions & 0 deletions src/app/Models/ConfigData.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,17 @@ public static function createGroup(
"data_type"=>DataType::YAP_GROUPS_V2
]);
}

public static function createVolunteer(
int $serviceBodyId,
int $parentServiceBodyId,
object $volunteerConfiguration
) : void {
self::create([
"service_body_id"=>$serviceBodyId,
"parent_id"=>$parentServiceBodyId,
"data"=>json_encode([$volunteerConfiguration]),
"data_type"=>DataType::YAP_VOLUNTEERS_V2
]);
}
}
Loading

0 comments on commit 4006b4a

Please sign in to comment.