Last active
November 20, 2024 21:41
-
-
Save lgaetz/40636245b6846f3aab372b22eb310e40 to your computer and use it in GitHub Desktop.
Campon Hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; FreePBX Dialplan to mimic the old Campon Feature in fpbx (Asterisk CCSS) | |
; | |
; License: GNU GPL3+ | |
; Latest version: https://gist.github.com/lgaetz/40636245b6846f3aab372b22eb310e40 | |
; | |
; | |
; The Goal: | |
; Watcher extension dials a prefix feature code and target extension. Once the target extension ends their current (or next) call, | |
; fpbx automatically sets up a call between the watcher and target extensions. Secondary goal, avoid AGI/ARI if possible | |
; | |
; The Plan: | |
; Create a feature code prefix that stores the watching extension number, the target extension number and a timedate stamp in astdb | |
; AstDB format CCSS/<target ext#>/<watcher ext#> = date time of DB record creation | |
; Set a hangup handler on every channel dialed by a local extension. Hangup handler looks in AstDB for any CCSS calls where | |
; the channel extension is set as the target (Asterisk function DB_KEYS will return comma separated list of keys with a specific prefix) | |
; If there are CCSS targets found in AstDB, check current time against the datestamp and purge if too stale (how many hours?) | |
; If there are valid CCSS targets found, dialplan ORIGINATE (or create call file) a call between the target and watching extensions | |
; If the new call is successful, delete the AstDB entry (not sure how to determine success AND match it to the AstDB record) | |
; | |
; version history 2024-11-20 First commit WORK IN PROGRESS - NOT FUNCTIONAL | |
[from-internal-custom] | |
exten => _**44XXXX,1,Noop() | |
exten => _**44XXXX,n,Gosub(macro-user-callerid,s,1) | |
exten => _**44XXXX,n,Set(CCSS_target=${EXTEN:4}) | |
exten => _**44XXXX,n,Set(CCSS_watcher=${AMPUSER}) | |
exten => _**44XXXX,n,Noop(setting AstDB entry for future call from ${CCSS_watcher} to ${CCSS_target}) | |
exten => _**44XXXX,n,Set(DB(CCSS/${CCSS_target}/${CCSS_from})=${EPOCH}) ; set dbase record with To,from numbers and current date/time | |
exten => _**44XXXX,n,hangup | |
[macro-dialout-one-predial-hook] | |
; TODO - identify remaining dialplan hooks | |
exten => s,1,Set(CHANNEL(hangup_handler_push)=app-ccss-hangup,s,1) | |
exten => s,n,Return | |
[app-ccss-hangup] | |
exten => s,1,Noop() | |
; exten => s,n,DumpChan() ; uncomment for debug | |
exten => s,n,Set(targets=${DB_KEYS(CCSS/${AMPUSER})}) ; gets an array of all AstDB entries which current channel as target | |
exten => s,n,ExecIf($["${targets}"=""]?Return) ; bail if array is empty | |
exten => s,n,SET(CCSS_watcher=${SHIFT(targets)}) ; isolate the first value in the array | |
exten => s,n,SET(CCSS_target=${AMPUSER}) | |
; TODO add a check to compare AstDB value of CCSS/${CCSS_target}/${CCSS_watcher} with current epoch time and delete record if more than X hours | |
; TODO Create the ORIGINATE Dialplan - maybe recreate AstDB record if ORIGINATE unsuccessful | |
; TODO delete AstDB record CCSS/${CCSS_target}/${CCSS_watcher} | |
exten => s,n,Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment