mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Add extension handling to subscriber (#7412)
* add extension handling to subscriber Store the extensions in the subscriber when it is available from $_SESSION. Add more documentation to functions and variables * remove rogue 'c' character injected by my keyboard * Store the user session information in the token when available * Add extension filter class * Create get_user_setting function * Add channel_presence_id key to event message
This commit is contained in:
@@ -54,6 +54,7 @@ class active_calls_service extends service implements websocket_service_interfac
|
||||
'unique_id',
|
||||
// Domain
|
||||
'caller_context',
|
||||
'channel_presence_id',
|
||||
// Ringing, Hangup, Answered
|
||||
'answer_state',
|
||||
'channel_call_state',
|
||||
@@ -103,6 +104,8 @@ class active_calls_service extends service implements websocket_service_interfac
|
||||
'application' => 'call_active_application',
|
||||
'playback_file_path' => 'call_active_application',
|
||||
'variable_current_application'=> 'call_active_application',
|
||||
'channel_presence_id' => 'call_active_view',
|
||||
'caller_context' => 'call_active_domain',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -186,11 +189,21 @@ class active_calls_service extends service implements websocket_service_interfac
|
||||
}
|
||||
|
||||
// Filter on single domain name
|
||||
if ($subscriber->has_permission('call_active_domain')) {
|
||||
return filter_chain::and_link([
|
||||
new event_filter(self::SWITCH_EVENTS),
|
||||
new permission_filter(self::PERMISSION_MAP, $subscriber->get_permissions()),
|
||||
new event_key_filter(self::EVENT_KEYS),
|
||||
new caller_context_filter([$subscriber->get_domain_name()]),
|
||||
]);
|
||||
}
|
||||
|
||||
// Filter on extensions
|
||||
return filter_chain::and_link([
|
||||
new event_filter(self::SWITCH_EVENTS),
|
||||
new permission_filter(self::PERMISSION_MAP, $subscriber->get_permissions()),
|
||||
new event_key_filter(self::EVENT_KEYS),
|
||||
new caller_context_filter([$subscriber->get_domain_name()]),
|
||||
new extension_filter($subscriber->get_user_setting('extension', [])),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
55
app/active_calls/resources/classes/extension_filter.php
Normal file
55
app/active_calls/resources/classes/extension_filter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* FusionPBX
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FusionPBX
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mark J Crane <markjcrane@fusionpbx.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008-2025
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark J Crane <markjcrane@fusionpbx.com>
|
||||
* Tim Fry <tim@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of extension_filter
|
||||
*
|
||||
* @author Tim Fry <tim@fusionpbx.com>
|
||||
*/
|
||||
class extension_filter {
|
||||
|
||||
private $extensions;
|
||||
|
||||
public function __construct(array $extensions = []) {
|
||||
//organize the extensions in a way we can use isset for fast lookup
|
||||
foreach ($extensions as $extension) {
|
||||
$presence_id = $extension['user'] . '@' . $extension['user_context'];
|
||||
$this->extensions[$presence_id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function __invoke(string $key, $value): ?bool {
|
||||
//only match on channel_presence_id key
|
||||
if ($key === 'channel_presence_id' && !isset($this->extensions[$value])) {
|
||||
// Drop the message
|
||||
return null;
|
||||
}
|
||||
//no key to match on
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user