Fix voicemail and queue announcement issues
- Fixed phone agents getting 'Unauthorized' error when accessing voicemails by checking for twp_access_voicemails capability - Fixed missing ElevenLabs parameter in queue TwiML generation that prevented announcement messages - Fixed IVR voicemail messages not being saved correctly - now properly assigns message field based on action type - Added proper permission checks for both ajax_get_voicemail and ajax_get_voicemail_audio functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3432,6 +3432,11 @@ class TWP_Admin {
|
|||||||
public function ajax_get_voicemail() {
|
public function ajax_get_voicemail() {
|
||||||
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
||||||
|
|
||||||
|
if (!current_user_can('manage_options') && !current_user_can('twp_access_voicemails')) {
|
||||||
|
wp_send_json_error('Unauthorized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$voicemail_id = intval($_POST['voicemail_id']);
|
$voicemail_id = intval($_POST['voicemail_id']);
|
||||||
|
|
||||||
if (!$voicemail_id) {
|
if (!$voicemail_id) {
|
||||||
@@ -3487,7 +3492,7 @@ class TWP_Admin {
|
|||||||
public function ajax_get_voicemail_audio() {
|
public function ajax_get_voicemail_audio() {
|
||||||
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
check_ajax_referer('twp_ajax_nonce', 'nonce');
|
||||||
|
|
||||||
if (!current_user_can('manage_options')) {
|
if (!current_user_can('manage_options') && !current_user_can('twp_access_voicemails')) {
|
||||||
wp_send_json_error('Unauthorized');
|
wp_send_json_error('Unauthorized');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -877,14 +877,32 @@ jQuery(document).ready(function($) {
|
|||||||
// console.log('Processing IVR options - raw data:', data);
|
// console.log('Processing IVR options - raw data:', data);
|
||||||
data.options = {};
|
data.options = {};
|
||||||
for (var i = 0; i < data.digit.length; i++) {
|
for (var i = 0; i < data.digit.length; i++) {
|
||||||
|
// Get the appropriate target value based on action type
|
||||||
|
var targetValue = data.target[i];
|
||||||
var option = {
|
var option = {
|
||||||
action: data.action[i],
|
action: data.action[i],
|
||||||
description: data.description[i],
|
description: data.description[i],
|
||||||
number: data.target[i],
|
number: '',
|
||||||
queue_name: data.target[i],
|
queue_name: '',
|
||||||
message: data.target[i]
|
message: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set the appropriate field based on action type
|
||||||
|
switch(data.action[i]) {
|
||||||
|
case 'forward':
|
||||||
|
option.number = targetValue;
|
||||||
|
break;
|
||||||
|
case 'queue':
|
||||||
|
option.queue_name = targetValue;
|
||||||
|
break;
|
||||||
|
case 'voicemail':
|
||||||
|
option.message = targetValue;
|
||||||
|
break;
|
||||||
|
case 'message':
|
||||||
|
option.message = targetValue;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// console.log('Processing option', i, '- action:', data.action[i], 'target:', data.target[i]);
|
// console.log('Processing option', i, '- action:', data.action[i], 'target:', data.target[i]);
|
||||||
|
|
||||||
// For queue action, get the actual queue name from the select option text
|
// For queue action, get the actual queue name from the select option text
|
||||||
|
@@ -975,7 +975,8 @@ class TWP_Workflow {
|
|||||||
return self::create_voicemail_twiml($action, $elevenlabs);
|
return self::create_voicemail_twiml($action, $elevenlabs);
|
||||||
|
|
||||||
case 'queue':
|
case 'queue':
|
||||||
return self::create_queue_twiml($action);
|
$elevenlabs = new TWP_ElevenLabs_API();
|
||||||
|
return self::create_queue_twiml($action, $elevenlabs);
|
||||||
|
|
||||||
case 'ring_group':
|
case 'ring_group':
|
||||||
return self::create_ring_group_twiml($action);
|
return self::create_ring_group_twiml($action);
|
||||||
|
Reference in New Issue
Block a user