Fix recording playback authentication and phone number display
Recording Playback Fixes: - Added proxy_recording_audio endpoint to handle authenticated playback - Recordings now play through WordPress proxy like voicemails - Updated Play/Download buttons to use proxy URLs instead of direct Twilio URLs - No more Twilio login prompts when playing recordings Phone Number Display Fixes: - Fixed outbound call recording display to show customer numbers properly - For browser phone outbound calls, customer number now shows in "From" field - Added logic to detect client: calls and swap number display appropriately - Enhanced logging for debugging outbound call number handling The recording system now works consistently with the voicemail system, providing seamless authenticated playback without exposing Twilio credentials. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2217,8 +2217,9 @@ class TWP_Admin {
|
||||
html += '<td>' + formatDuration(recording.duration) + '</td>';
|
||||
html += '<td>';
|
||||
if (recording.has_recording) {
|
||||
html += '<button class="button button-small" onclick="playRecording(\'' + recording.recording_url + '\')">Play</button> ';
|
||||
html += '<a href="' + recording.recording_url + '" class="button button-small" download>Download</a>';
|
||||
var proxyUrl = '<?php echo home_url('/wp-json/twilio-webhook/v1/recording-audio/'); ?>' + recording.id;
|
||||
html += '<button class="button button-small" onclick="playRecording(\'' + proxyUrl + '\')">Play</button> ';
|
||||
html += '<a href="' + proxyUrl + '" class="button button-small" download>Download</a>';
|
||||
<?php if (current_user_can('manage_options')): ?>
|
||||
html += ' <button class="button button-small button-link-delete" onclick="deleteRecording(' + recording.id + ')">Delete</button>';
|
||||
<?php endif; ?>
|
||||
@@ -7415,11 +7416,24 @@ class TWP_Admin {
|
||||
global $wpdb;
|
||||
$recordings_table = $wpdb->prefix . 'twp_call_recordings';
|
||||
|
||||
// For outbound calls from browser phone, swap the numbers for better display
|
||||
$from_number = $call->from;
|
||||
$to_number = $call->to;
|
||||
|
||||
// If this is a browser phone call (from contains 'client:'), then the customer is the 'to' number
|
||||
if (strpos($call->from, 'client:') === 0) {
|
||||
// This is an outbound call from browser phone
|
||||
// Store the customer number as 'from' for display consistency
|
||||
$from_number = $call->to; // Customer number
|
||||
$to_number = $call->from; // Browser phone client
|
||||
error_log("TWP: Outbound browser call - Customer: {$call->to}, Agent: {$call->from}");
|
||||
}
|
||||
|
||||
$insert_result = $wpdb->insert($recordings_table, [
|
||||
'call_sid' => $call_sid,
|
||||
'recording_sid' => $recording->sid,
|
||||
'from_number' => $call->from,
|
||||
'to_number' => $call->to,
|
||||
'from_number' => $from_number,
|
||||
'to_number' => $to_number,
|
||||
'agent_id' => $user_id,
|
||||
'status' => 'recording',
|
||||
'started_at' => current_time('mysql')
|
||||
|
Reference in New Issue
Block a user