You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
4.6 KiB
87 lines
4.6 KiB
From: Sipwise Development Team <support@sipwise.com>
|
|
Date: Mon, 4 Nov 2024 15:37:29 +0100
|
|
Subject: sipwise_vm_add_callid
|
|
|
|
---
|
|
apps/app_voicemail.c | 22 ++++++++++++++++------
|
|
1 file changed, 16 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
|
|
index 817c32c..d76467d 100644
|
|
--- a/apps/app_voicemail.c
|
|
+++ b/apps/app_voicemail.c
|
|
@@ -940,7 +940,7 @@ static char odbc_database[80] = "asterisk";
|
|
static char odbc_table[80] = "voicemessages";
|
|
#define RETRIEVE(a,b,c,d) retrieve_file(a,b)
|
|
#define DISPOSE(a,b) remove_file(a,b)
|
|
-#define STORE(a,b,c,d,e,f,g,h,i,j,k) store_file(a,b,c,d)
|
|
+#define STORE(a,b,c,d,e,f,g,h,i,j,k) store_file(a,b,c,d,e)
|
|
#define EXISTS(a,b,c,d) (message_exists(a,b))
|
|
#define RENAME(a,b,c,d,e,f,g,h) (rename_file(a,b,c,d,e,f))
|
|
#define COPY(a,b,c,d,e,f,g,h) (copy_file(a,b,c,d,e,f))
|
|
@@ -4564,6 +4564,7 @@ struct insert_data {
|
|
const char *category;
|
|
const char *flag;
|
|
const char *msg_id;
|
|
+ const char *call_id;
|
|
};
|
|
|
|
static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata)
|
|
@@ -4592,6 +4593,9 @@ static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata)
|
|
SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msg_id), 0, (void *) data->msg_id, 0, NULL);
|
|
if (!ast_strlen_zero(data->category)) {
|
|
SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL);
|
|
+ SQLBindParameter(stmt, 14, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->call_id), 0, (void *) data->call_id, 0, NULL);
|
|
+ } else {
|
|
+ SQLBindParameter(stmt, 13, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->call_id), 0, (void *) data->call_id, 0, NULL);
|
|
}
|
|
res = ast_odbc_execute_sql(obj, stmt, data->sql);
|
|
if (!SQL_SUCCEEDED(res)) {
|
|
@@ -4616,7 +4620,7 @@ static SQLHSTMT insert_data_cb(struct odbc_obj *obj, void *vdata)
|
|
*
|
|
* \return the zero on success -1 on error.
|
|
*/
|
|
-static int store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum)
|
|
+static int store_file(const char *dir, const char *mailboxuser, const char *mailboxcontext, int msgnum, struct ast_channel *chan)
|
|
{
|
|
int res = 0;
|
|
int fd = -1;
|
|
@@ -4631,8 +4635,9 @@ static int store_file(const char *dir, const char *mailboxuser, const char *mail
|
|
char *c;
|
|
struct ast_config *cfg = NULL;
|
|
struct odbc_obj *obj;
|
|
+ const char *call_id;
|
|
struct insert_data idata = { .sql = sql, .msgnums = msgnums, .dir = dir, .mailboxuser = mailboxuser, .mailboxcontext = mailboxcontext,
|
|
- .context = "", .macrocontext = "", .callerid = "", .origtime = "", .duration = "", .category = "", .flag = "", .msg_id = "" };
|
|
+ .context = "", .macrocontext = "", .callerid = "", .origtime = "", .duration = "", .category = "", .flag = "", .msg_id = "", call_id = "" };
|
|
struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
|
|
|
|
delete_file(dir, msgnum);
|
|
@@ -4705,10 +4710,15 @@ static int store_file(const char *dir, const char *mailboxuser, const char *mail
|
|
idata.data = fdm;
|
|
idata.datalen = idata.indlen = fdlen;
|
|
|
|
+ if ((call_id = pbx_builtin_getvar_helper(chan, "SIPCALLID"))) {
|
|
+ if (!ast_strlen_zero(call_id))
|
|
+ idata.call_id = ast_strdupa(call_id);
|
|
+ }
|
|
+
|
|
if (!ast_strlen_zero(idata.category))
|
|
- snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,msg_id,category) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", odbc_table);
|
|
+ snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,msg_id,category,call_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", odbc_table);
|
|
else
|
|
- snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,msg_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", odbc_table);
|
|
+ snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,msg_id,call_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", odbc_table);
|
|
|
|
if (ast_strlen_zero(idata.origtime)) {
|
|
idata.origtime = "0";
|
|
@@ -7065,7 +7075,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|
if (success == -1) {
|
|
/* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */
|
|
ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n");
|
|
- store_file(prefile, vmu->mailbox, vmu->context, -1);
|
|
+ store_file(prefile, vmu->mailbox, vmu->context, -1, chan);
|
|
}
|
|
#endif
|
|
} else {
|