Add FCM push notifications, queue alerts, caller ID fixes, and auto-revert agent status
All checks were successful
Create Release / build (push) Successful in 6s
All checks were successful
Create Release / build (push) Successful in 6s
Server-side: - Add push credential auto-creation for FCM incoming call notifications - Add queue alert FCM notifications (data-only for background delivery) - Add queue alert cancellation on call accept/disconnect - Fix caller ID to show caller's number instead of Twilio number - Fix FCM token storage when refresh_token is null - Add pre_call_status tracking to revert agent status 30s after call ends - Add SSE fallback polling for mobile app connectivity Mobile app: - Add Android telecom permissions and phone account registration - Add VoiceFirebaseMessagingService for incoming call push handling - Add insistent queue alert notifications with custom sound - Fix caller number display on active call screen - Add caller ID selection dropdown on dashboard - Add phone numbers endpoint and provider support - Add unit tests for CallInfo, QueueState, and CallProvider - Remove local.properties from tracking, add .gitignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,8 +33,8 @@ class TWP_Call_Queue {
|
||||
);
|
||||
|
||||
if ($result !== false) {
|
||||
// Notify agents via SMS when a new call enters the queue
|
||||
self::notify_agents_for_queue($queue_id, $call_data['from_number']);
|
||||
// Notify agents via SMS and FCM when a new call enters the queue
|
||||
self::notify_agents_for_queue($queue_id, $call_data['from_number'], $call_data['call_sid']);
|
||||
return $position;
|
||||
}
|
||||
|
||||
@@ -580,49 +580,60 @@ class TWP_Call_Queue {
|
||||
/**
|
||||
* Notify agents via SMS when a call enters the queue
|
||||
*/
|
||||
private static function notify_agents_for_queue($queue_id, $caller_number) {
|
||||
private static function notify_agents_for_queue($queue_id, $caller_number, $call_sid = '') {
|
||||
global $wpdb;
|
||||
|
||||
|
||||
error_log("TWP: notify_agents_for_queue called for queue {$queue_id}, caller {$caller_number}");
|
||||
|
||||
|
||||
// Get queue information including assigned agent group and phone number
|
||||
$queue_table = $wpdb->prefix . 'twp_call_queues';
|
||||
$queue = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT * FROM $queue_table WHERE id = %d",
|
||||
$queue_id
|
||||
));
|
||||
|
||||
|
||||
if (!$queue) {
|
||||
error_log("TWP: Queue {$queue_id} not found in database");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$queue->agent_group_id) {
|
||||
error_log("TWP: No agent group assigned to queue {$queue_id}, skipping SMS notifications");
|
||||
return;
|
||||
}
|
||||
|
||||
error_log("TWP: Found queue '{$queue->queue_name}' with agent group {$queue->agent_group_id}");
|
||||
|
||||
|
||||
// Send Discord/Slack notification for incoming call
|
||||
require_once dirname(__FILE__) . '/class-twp-notifications.php';
|
||||
error_log("TWP: Triggering Discord/Slack notification for incoming call");
|
||||
TWP_Notifications::send_call_notification('incoming_call', array(
|
||||
'type' => 'incoming_call',
|
||||
'caller' => $caller_number,
|
||||
'queue' => $queue->queue_name,
|
||||
'queue_id' => $queue_id
|
||||
));
|
||||
|
||||
// Get members of the assigned agent group
|
||||
require_once dirname(__FILE__) . '/class-twp-agent-groups.php';
|
||||
$members = TWP_Agent_Groups::get_group_members($queue->agent_group_id);
|
||||
|
||||
// Send FCM push notifications to agents' mobile devices
|
||||
require_once dirname(__FILE__) . '/class-twp-fcm.php';
|
||||
$fcm = new TWP_FCM();
|
||||
$notified_users = array();
|
||||
|
||||
// Always notify personal queue owner
|
||||
if (!empty($queue->user_id)) {
|
||||
$fcm->notify_queue_alert($queue->user_id, $caller_number, $queue->queue_name, $call_sid);
|
||||
$notified_users[] = $queue->user_id;
|
||||
error_log("TWP: FCM queue alert sent to queue owner user {$queue->user_id}");
|
||||
}
|
||||
|
||||
if (!$queue->agent_group_id) {
|
||||
error_log("TWP: No agent group assigned to queue {$queue_id}, skipping SMS notifications");
|
||||
return;
|
||||
}
|
||||
|
||||
error_log("TWP: Found queue '{$queue->queue_name}' with agent group {$queue->agent_group_id}");
|
||||
|
||||
// Get members of the assigned agent group
|
||||
require_once dirname(__FILE__) . '/class-twp-agent-groups.php';
|
||||
$members = TWP_Agent_Groups::get_group_members($queue->agent_group_id);
|
||||
|
||||
foreach ($members as $member) {
|
||||
$fcm->notify_incoming_call($member->user_id, $caller_number, $queue->queue_name, '');
|
||||
if (!in_array($member->user_id, $notified_users)) {
|
||||
$fcm->notify_queue_alert($member->user_id, $caller_number, $queue->queue_name, $call_sid);
|
||||
$notified_users[] = $member->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($members)) {
|
||||
|
||||
Reference in New Issue
Block a user