Skip to content

Commit

Permalink
busy number handling #971 (#1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman authored May 5, 2024
1 parent 4006b4a commit 8a3bb65
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 179 deletions.
2 changes: 1 addition & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### 4.3.4 (UNRELEASED)
* Fix for dialback dialing. [#1021]
* Fix for when an invalid or out of service number is specified for a volunteer. [#971]
* Fix for when an invalid or busy 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 @@ -29,6 +29,7 @@ class EventId
const SPAD_LOOKUP_SMS = 24;
const VOLUNTEER_SEARCH_FORCE_DIALED = 25;
const VOLUNTEER_NUMBER_BAD = 26;
const VOLUNTEER_NUMBER_BUSY = 27;

public static function getEventById($id)
{
Expand Down Expand Up @@ -85,6 +86,8 @@ public static function getEventById($id)
return "Volunteer Search Force Dial";
case self::VOLUNTEER_NUMBER_BAD:
return "Volunteer Number is Bad";
case self::VOLUNTEER_NUMBER_BUSY:
return "Volunteer Number is Busy";
}
}
}
18 changes: 16 additions & 2 deletions src/app/Http/Controllers/HelplineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ public function dial(Request $request)
{
if ($request->has('noop')) {
if ($request->has('CallStatus') &&
($request->get('CallStatus') == TwilioCallStatus::NOANSWER || $request->get('CallStatus') == TwilioCallStatus::FAILED)) {
($request->get('CallStatus') == TwilioCallStatus::NOANSWER
|| $request->get('CallStatus') == TwilioCallStatus::FAILED
|| $request->get('CallStatus') == TwilioCallStatus::BUSY)) {
$this->twilio->incrementNoAnswerCount();
}

Expand Down Expand Up @@ -301,7 +303,11 @@ public function dial(Request $request)

// 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->get('CallStatus') == TwilioCallStatus::FAILED ))) {
( $request->has('CallStatus') &&
($request->get('CallStatus') == TwilioCallStatus::NOANSWER
|| $request->get('CallStatus') == TwilioCallStatus::COMPLETED
|| $request->get('CallStatus') == TwilioCallStatus::FAILED
|| $request->get('CallStatus') == TwilioCallStatus::BUSY ))) {
$callConfig = $this->getCallConfig($request, $serviceBodyCallHandling);

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

Log::debug("Next volunteer to call " . $callConfig->volunteer->phoneNumber);
Expand Down
15 changes: 14 additions & 1 deletion src/app/Models/ConfigData.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function createGroup(
public static function createVolunteer(
int $serviceBodyId,
int $parentServiceBodyId,
object $volunteerConfiguration
VolunteerData $volunteerConfiguration
) : void {
self::create([
"service_body_id"=>$serviceBodyId,
Expand All @@ -63,4 +63,17 @@ public static function createVolunteer(
"data_type"=>DataType::YAP_VOLUNTEERS_V2
]);
}

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

0 comments on commit 8a3bb65

Please sign in to comment.