From 54a9c72b4e3a6d8bed2119711769e380173b1eff Mon Sep 17 00:00:00 2001 From: Danny Gershman Date: Sun, 27 Aug 2023 12:19:53 -0400 Subject: [PATCH] backporting retry logic --- RELEASENOTES.md | 3 +++ legacy/_includes/functions.php | 2 +- legacy/helpline-dialer.php | 13 ++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 594c0492d..926b74f75 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,8 @@ # Release Notes +### 4.2.11 (UNRELEASED) +* Sometime in August 2023, Twilio introduced a change in API Behavior. The conferences API now seems to be eventually consistent. This change adds retry logic that addresses this timing issue. + ### 4.2.10 (July 2, 2023) * Added explicit notification that SMS will be sent in response to meeting search request; reflected this in report. This is to satisfy regulatory requirements regarding explicit consent. diff --git a/legacy/_includes/functions.php b/legacy/_includes/functions.php index bb96ab157..4ef27e778 100644 --- a/legacy/_includes/functions.php +++ b/legacy/_includes/functions.php @@ -21,7 +21,7 @@ if (isset($_GET["CallSid"])) { insertSession($_GET["CallSid"]); } -$GLOBALS['version'] = "4.2.10"; +$GLOBALS['version'] = "4.2.11"; $GLOBALS['settings_allowlist'] = [ 'announce_servicebody_volunteer_routing' => [ 'description' => '/helpline/announce_servicebody_volunteer_routing' , 'default' => false, 'overridable' => true, 'hidden' => false], 'blocklist' => [ 'description' => '/general/blocklist' , 'default' => '', 'overridable' => true, 'hidden' => false], diff --git a/legacy/helpline-dialer.php b/legacy/helpline-dialer.php index 96590c040..b612dcba5 100644 --- a/legacy/helpline-dialer.php +++ b/legacy/helpline-dialer.php @@ -76,7 +76,18 @@ function getCallConfig($serviceBodyCallHandling) exit(); } -$conferences = $twilioClient->conferences->read(array ("friendlyName" => $_REQUEST['FriendlyName'] )); +$conferences = []; +for ($i = 0; $i < 7; $i++) { + $conferences = $twilioClient->conferences->read(array ("friendlyName" => $_REQUEST['FriendlyName'] )); + if ($i > 0) { + log_debug("conferences eventual consistency issue, retry $i"); + } + if (count($conferences)) { + break; + } + sleep(0.5); +} + if (count($conferences) > 0 && $conferences[0]->status != "completed") { $sms_body = word('you_have_an_incoming_phoneline_call_from') . " ";