diff options
author | Ted Trask <ttrask01@yahoo.com> | 2016-02-17 21:58:14 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2016-02-17 21:58:14 +0000 |
commit | e0c9a43169c3a90661574c86e9a918950a0cc0dd (patch) | |
tree | d4c42d23e1f36168e97c4896c6d535478e1f946f /vmail-model.lua | |
parent | f2b741e67b698590e15d3d65183dfb9b70b96ed8 (diff) | |
download | acf-freeswitch-vmail-e0c9a43169c3a90661574c86e9a918950a0cc0dd.tar.bz2 acf-freeswitch-vmail-e0c9a43169c3a90661574c86e9a918950a0cc0dd.tar.xz |
Change download(my)message to use proper cfe and new stream template
Diffstat (limited to 'vmail-model.lua')
-rw-r--r-- | vmail-model.lua | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/vmail-model.lua b/vmail-model.lua index d129fdf..37b0c2d 100644 --- a/vmail-model.lua +++ b/vmail-model.lua @@ -456,27 +456,35 @@ mymodule.list_messages = function(username) return cfe({ type="structure", value=retval, label="Messages", errtxt=errtxt }) end -mymodule.get_message = function(message, username) - local retval = cfe({ type="raw", label="error", option="audio/x-wav" }) +mymodule.get_download_message = function(self, clientdata) + local result = {} + result.message = cfe({ label="Message" }) + result.username = cfe({ label="User Name" }) + return cfe({ type="group", value=result, label="Download Message" }) +end + +mymodule.download_message = function(self, downloadrequest) + local file = cfe({ type="raw", label="error", option="audio/x-wav" }) local res, err = pcall(function() local connected = vmaildb.databaseconnect() local sql = "SELECT username, file_path FROM voicemail_msgs" - sql = sql .. generatewhereclause(username, message) + sql = sql .. generatewhereclause(downloadrequest.value.username.value, downloadrequest.value.message.value) local tmp = vmaildb.getselectresponse(sql) if connected then databasedisconnect() end if #tmp == 0 then - retval.errtxt = "Invalid message" + downloadrequest.errtxt = "Invalid message" else - retval.label = posix.basename(tmp[1].file_path) - retval.value = fs.read_file(tmp[1].file_path) + file.label = posix.basename(tmp[1].file_path) + file.value = fs.read_file(tmp[1].file_path) -- Mark the message as read - voicemail_read(tmp[1].username, config.domain, message) + voicemail_read(tmp[1].username, config.domain, downloadrequest.value.message.value) end + downloadrequest.value.file = file end) if not res and err then - retval.errtxt = err + downloadrequest.errtxt = err end - return retval + return downloadrequest end mymodule.get_delete_message = function(self, clientdata) |