Skip to content

Commit e4f4050

Browse files
Merge pull request #175 from sebastian-king/master
hotfixes from production to untr master
2 parents afa63a5 + 0360c3b commit e4f4050

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

api/sendgrid-inbound/parse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'" . $db->real_escape_string($name) . "',
2525
'" . $db->real_escape_string($email) . "',
2626
'" . $db->real_escape_string("orgsync/inbound-parse") . "',
27-
'" . $db->real_escape_string(bin2hex(random_bytes(16))) . "'
27+
'" . $db->real_escape_string($token) . "'
2828
)");
2929

3030
AdminBot::send_message("{$name} ({$email}) db write attempt (" . $token . "): " . $db->insert_id . "/" . $db->affected_rows);

template/top.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function email($to, $subject, $message, $replyto = false, $headers = NULL, $atta
9898
$email = new \SendGrid\Mail\Mail();
9999
$email->setFrom("no-reply@untrobotics.com", "UNT Robotics");
100100
$email->setSubject($subject);
101+
$email->addBcc("sebastian-king@my.unt.edu");
101102

102103
if ($replyto) {
103104
$email->setReplyTo($replyto);

twilio/find-first/find-first-available.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
require('../phone-numbers-config.php');
1919

20-
function dial_attempt($phone_number) {
20+
function dial_attempt($incoming_sid, $phone_number) {
2121
$ch = curl_init();
2222

2323
$post = array(
@@ -40,14 +40,14 @@ function dial_attempt($phone_number) {
4040

4141
$data = json_decode($result);
4242

43-
error_log("DIAL ATTEMPT: " . var_export($result, true));
43+
error_log("[$incoming_sid] DIAL ATTEMPT. TO:" . $data->to);
4444

4545
return $data->sid;
4646
}
4747

4848
function call_completed($sid) {
4949

50-
$status = call_status($sid);
50+
$status = call_info($sid)->status;
5151

5252
$final_status = array('busy', 'no-answer', 'canceled', 'failed', 'completed');
5353

@@ -58,27 +58,27 @@ function call_completed($sid) {
5858
return false;
5959
}
6060

61-
function call_status($sid) {
61+
function call_info($sid) {
6262

63-
$ch = curl_init();
63+
$ch = curl_init();
6464

65-
curl_setopt($ch, CURLOPT_URL, 'https://api.twilio.com/2010-04-01/Accounts/' . TWILIO_ACCOUNT_SID . '/Calls/' . $sid . '.json');
66-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
67-
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
65+
curl_setopt($ch, CURLOPT_URL, 'https://api.twilio.com/2010-04-01/Accounts/' . TWILIO_ACCOUNT_SID . '/Calls/' . $sid . '.json');
66+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
67+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
6868

69-
curl_setopt($ch, CURLOPT_USERPWD, TWILIO_ACCOUNT_SID . ':' . TWILIO_AUTH_TOKEN);
69+
curl_setopt($ch, CURLOPT_USERPWD, TWILIO_ACCOUNT_SID . ':' . TWILIO_AUTH_TOKEN);
7070

71-
$result = curl_exec($ch);
72-
if (curl_errno($ch)) {
73-
error_log('ERROR (curl) when getting message SID info: ' . curl_error($ch));
74-
}
75-
curl_close($ch);
71+
$result = curl_exec($ch);
72+
if (curl_errno($ch)) {
73+
error_log('ERROR (curl) when getting message SID info: ' . curl_error($ch));
74+
}
75+
curl_close($ch);
7676

77-
$data = json_decode($result);
78-
79-
error_log("OUTGOING CALL STATUS: " . $data);
80-
81-
return $data->status;
77+
$data = json_decode($result);
78+
79+
//error_log("OUTGOING CALL STATUS: " . var_export($data, true));
80+
81+
return $data;
8282
}
8383

8484
function queue_size($queue_sid = TWILIO_FIND_FIRST_QUEUE_SID) {
@@ -114,13 +114,15 @@ function queue_size($queue_sid = TWILIO_FIND_FIRST_QUEUE_SID) {
114114
$max_attempts = 5;
115115
$i = 1;
116116

117+
error_log("[$incoming_sid] INCOMING CALL. FROM:" . call_info($incoming_sid)->from);
118+
117119
while ($i <= $max_attempts) {
118120
foreach (constant('PHONE_NUMBERS') as $phone_number) {
119121
if (queue_size() > 0) {
120-
$outgoing_sid = dial_attempt($phone_number);
122+
$outgoing_sid = dial_attempt($incoming_sid, $phone_number);
121123
do {
122-
error_log("INCOMING CALL STATUS: " . call_status($incoming_sid));
123-
sleep(1);
124+
//error_log("INCOMING CALL STATUS: " . call_status($incoming_sid));
125+
sleep(2);
124126
} while (!call_completed($outgoing_sid) && queue_size() > 0);
125127
} else {
126128
break 2;
@@ -129,4 +131,4 @@ function queue_size($queue_sid = TWILIO_FIND_FIRST_QUEUE_SID) {
129131
$i++;
130132
}
131133

132-
error_log("INCOMING CALL STATUS LAST: " . call_status($incoming_sid));
134+
error_log("[$incoming_sid] INCOMING CALL STATUS LAST: " . call_info($incoming_sid)->status);

twilio/process-incoming-call.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,26 @@
1717
<Gather input="dtmf" timeout="10" numDigits="1" action="/twilio/process-incoming-call.php?code=<?php echo API_SECRET; ?>">
1818
<Pause length="2"/>
1919
<Say voice="woman" language="en-GB">
20-
Press 2 for Sebastian King, Co-President.
21-
3 for Lauren Caves, Co-President.
22-
4 for Tyler Martinez, Vice-President.
23-
5 for Ashank Annam, Corporate Relation.
24-
6 for Lauren Caves, Secretary.
20+
Press 2 for Nicholas Tindle, Co-President.
21+
3 for Laurence Boyd, Vice-President.
22+
4 for Carter Moore, Secretary.
23+
5 for Sophia Casas, Corporate Relation.
2524
</Say>
2625
</Gather>
2726
<?php
2827
break;
2928
case 2:
30-
?><Dial><?php echo PHONE_NUMBERS['SebK']; ?></Dial><?php
29+
?><Dial><?php echo PHONE_NUMBERS['NickT']; ?></Dial><?php
3130
break;
3231
case 3:
33-
?><Dial><?php echo PHONE_NUMBERS['LaurenC']; ?></Dial><?php
32+
?><Dial><?php echo PHONE_NUMBERS['LaurenceB']; ?></Dial><?php
3433
break;
3534
case 4:
36-
?><Dial><?php echo PHONE_NUMBERS['TylerM']; ?></Dial><?php
35+
?><Dial><?php echo PHONE_NUMBERS['CarterM']; ?></Dial><?php
3736
break;
3837
case 5:
39-
?><Dial><?php echo PHONE_NUMBERS['AshankA']; ?></Dial><?php
38+
?><Dial><?php echo PHONE_NUMBERS['SophiaC']; ?></Dial><?php
4039
break;
41-
case 6:
42-
?><Dial><?php echo PHONE_NUMBERS['LaurenC']; ?></Dial><?php
43-
break;
4440
case 9: // Voicemail
4541
?>
4642
<Say voice="woman" language="en-GB">

0 commit comments

Comments
 (0)