Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
acf-freeswitch-vmail
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ACF
acf-freeswitch-vmail
Commits
25724c1c
Commit
25724c1c
authored
Apr 12, 2015
by
Ted Trask
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Event Socket access by using luasocket library rather than nc and run_executable
parent
59364f1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
vmail-model.lua
vmail-model.lua
+32
-16
No files found.
vmail-model.lua
View file @
25724c1c
...
...
@@ -8,6 +8,7 @@ format = require("acf.format")
validator
=
require
(
"acf.validator"
)
db
=
require
(
"acf.db"
)
session
=
require
(
"session"
)
socket
=
require
(
"socket"
)
-- Set variables
local
configfile
=
"/etc/freeswitchvmail.conf"
...
...
@@ -82,37 +83,52 @@ vmaildb.table_creation_scripts = {
-- ################################################################################
-- LOCAL FUNCTIONS
-- Use socket.protect to create a function that will not throw exceptions and cleans itself up
local
send_to_event_socket
=
socket
.
protect
(
function
(
cmd
)
-- connect to freeswitch
local
conn
=
socket
.
try
(
socket
.
connect
(
config
.
event_socket_ip
,
config
.
event_socket_port
))
-- create a try function that closes 'conn' on error
local
try
=
socket
.
newtry
(
function
()
conn
:
close
()
end
)
-- do everything reassured conn will be closed
local
out
=
{}
repeat
out
[
#
out
+
1
]
=
try
(
conn
:
receive
())
until
out
[
#
out
]
==
""
for
i
,
c
in
ipairs
(
cmd
)
do
posix
.
sleep
(
0
)
try
(
conn
:
send
(
c
..
"
\n\n
"
))
repeat
out
[
#
out
+
1
]
=
try
(
conn
:
receive
())
until
out
[
#
out
]
==
""
end
conn
:
close
()
return
table.concat
(
out
,
"
\n
"
)
or
""
end
)
local
function
voicemail_inject
(
user
,
domain
,
sound_file
,
cid_num
,
cid_name
)
local
cmd
=
"auth "
..
config
.
event_socket_password
..
"
\n\n
"
cmd
=
cmd
..
"api voicemail_inject "
..
user
..
"@"
..
domain
..
" "
..
sound_file
..
" "
..
cid_num
..
" "
..
string.gsub
(
cid_name
,
" "
,
"%%20"
)
cmd
=
cmd
..
"
\n\n
exit\n\n"
return
modelfunctions
.
run_executable
({
"nc"
,
config
.
event_socket_ip
,
config
.
event_socket_port
},
true
,
cmd
)
local
cmd
=
{
"auth "
..
config
.
event_socket_password
,
"api voicemail_inject "
..
user
..
"@"
..
domain
..
" "
..
sound_file
..
" "
..
cid_num
..
" "
..
string.gsub
(
cid_name
,
" "
,
"%%20"
),
"exit"
}
return
send_to_event_socket
(
cmd
)
end
local
function
voicemail_callback
(
extension
,
sound_file
,
username
)
local
cmd
=
"auth "
..
config
.
event_socket_password
..
"
\n\n
bgapi "
local
c
=
config
.
callback_command
c
=
c
:
gsub
(
"%$1"
,
extension
)
c
=
c
:
gsub
(
"%$2"
,
sound_file
)
c
=
c
:
gsub
(
"%$3"
,
username
)
cmd
=
cmd
..
c
cmd
=
cmd
..
"
\n\n
exit\n\n"
return
modelfunctions
.
run_executable
({
"nc"
,
config
.
event_socket_ip
,
config
.
event_socket_port
},
true
,
cmd
)
local
cmd
=
{
"auth "
..
config
.
event_socket_password
,
"bgapi "
..
c
,
"exit"
}
return
send_to_event_socket
(
cmd
)
end
-- Need to update the voicemail module to turn off MWI
local
function
voicemail_update
(
user
,
domain
)
local
cmd
=
"auth "
..
config
.
event_socket_password
..
"
\n\n
"
cmd
=
cmd
..
"api vm_list "
..
user
..
"@"
..
domain
cmd
=
cmd
..
"
\n\n
exit\n\n"
return
modelfunctions
.
run_executable
({
"nc"
,
config
.
event_socket_ip
,
config
.
event_socket_port
},
true
,
cmd
)
local
cmd
=
{
"auth "
..
config
.
event_socket_password
,
"api vm_list "
..
user
..
"@"
..
domain
,
"exit"
}
return
send_to_event_socket
(
cmd
)
end
local
function
voicemail_read
(
user
,
domain
,
message
)
local
cmd
=
"auth "
..
config
.
event_socket_password
..
"
\n\n
"
cmd
=
cmd
..
"api vm_read "
..
user
..
"@"
..
domain
..
" read "
..
message
cmd
=
cmd
..
"
\n\n
exit\n\n"
return
modelfunctions
.
run_executable
({
"nc"
,
config
.
event_socket_ip
,
config
.
event_socket_port
},
true
,
cmd
)
local
cmd
=
{
"auth "
..
config
.
event_socket_password
,
"api vm_read "
..
user
..
"@"
..
domain
..
" read "
..
message
,
"exit"
}
return
send_to_event_socket
(
cmd
)
end
local
databasedisconnect
=
function
()
...
...
Ted Trask
@ttrask01
mentioned in commit
fccf0a0a
·
Oct 06, 2019
mentioned in commit
fccf0a0a
mentioned in commit fccf0a0a8d764f64416b294c880dbe8ead38309b
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment