" file_path VARCHAR(255),\n"
" message_len INTEGER,\n"
" flags VARCHAR(255),\n"
- " read_flags VARCHAR(255)\n"
+ " read_flags VARCHAR(255),\n"
+ " forwarded_by VARCHAR(255)\n"
");\n";
static char vm_pref_sql[] =
"create index voicemail_msgs_idx4 on voicemail_msgs(uuid)",
"create index voicemail_msgs_idx5 on voicemail_msgs(in_folder)",
"create index voicemail_msgs_idx6 on voicemail_msgs(read_flags)",
+ "create index voicemail_msgs_idx7 on voicemail_msgs(forwarded_by)",
"create index voicemail_prefs_idx1 on voicemail_prefs(username)",
"create index voicemail_prefs_idx2 on voicemail_prefs(domain)",
NULL
if (switch_thread_rwlock_trywrlock(profile->rwlock) != SWITCH_STATUS_SUCCESS) {
/* Lock failed, set the destroy flag so it'll be destroyed whenever its not in use anymore */
switch_set_flag(profile, PFLAG_DESTROY);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Profile is in use, memory will be freed whenever its not longer in use\n", profile->name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Profile is in use, memory will be freed whenever its no longer in use\n", profile->name);
return;
}
}
goto end;
}
- switch_cache_db_test_reactive(dbh, "select count(message_len) from voicemail_msgs", "drop table voicemail_msgs", vm_sql);
+ switch_cache_db_test_reactive(dbh, "select count(forwarded_by) from voicemail_msgs", NULL, "alter table voicemail_msgs add forwarded_by varchar(255)");
+ switch_cache_db_test_reactive(dbh, "select count(forwarded_by) from voicemail_msgs", "drop table voicemail_msgs", vm_sql);
+
switch_cache_db_test_reactive(dbh, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql);
switch_cache_db_test_reactive(dbh, "select count(password) from voicemail_prefs", NULL, "alter table voicemail_prefs add password varchar(255)");
char message_len[255];
char flags[255];
char read_flags[255];
+ char forwarded_by[255];
char *email;
int index;
int want;
switch_copy_string(cbt->message_len, argv[9], 255);
switch_copy_string(cbt->flags, argv[10], 255);
switch_copy_string(cbt->read_flags, argv[11], 255);
+ switch_copy_string(cbt->forwarded_by, argv[12], 255);
return -1;
}
static switch_status_t deliver_vm(vm_profile_t *profile,
- switch_xml_t x_user,
- const char *domain_name,
- const char *path,
- uint32_t message_len,
- const char *read_flags,
- switch_event_t *params,
- switch_memory_pool_t *pool,
- const char *caller_id_name,
- const char *caller_id_number,
- switch_bool_t copy)
+ switch_xml_t x_user,
+ const char *domain_name,
+ const char *path,
+ uint32_t message_len,
+ const char *read_flags,
+ switch_event_t *params,
+ switch_memory_pool_t *pool,
+ const char *caller_id_name,
+ const char *caller_id_number,
+ const char *forwarded_by,
+ switch_bool_t copy)
{
char *file_path = NULL, *dir_path = NULL;
const char *myid = switch_xml_attr(x_user, "id");
switch_event_fire(&message_event);
usql = switch_mprintf("insert into voicemail_msgs(created_epoch, read_epoch, username, domain, uuid, cid_name, "
- "cid_number, in_folder, file_path, message_len, flags, read_flags) "
- "values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_epoch_time_now(NULL),
+ "cid_number, in_folder, file_path, message_len, flags, read_flags, forwarded_by) "
+ "values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q','%q')", (long) switch_epoch_time_now(NULL),
myid, domain_name, uuid_str, caller_id_name, caller_id_number,
- myfolder, file_path, message_len, read_flags);
+ myfolder, file_path, message_len, read_flags, switch_str_nil(forwarded_by));
vm_execute_sql(profile, usql, profile->mutex);
switch_safe_free(usql);
switch_status_t status = SWITCH_STATUS_SUCCESS;
int isgroup = 0, isall = 0;
int argc = 0;
- char *argv[4];
+ char *argv[5] = { 0 };
char *box, *path, *cid_num, *cid_name;
switch_memory_pool_t *pool = NULL;
+ char *forwarded_by = NULL;
if (zstr(data)) {
status = SWITCH_STATUS_FALSE;
path = argv[1];
cid_num = argv[2] ? argv[2] : "anonymous";
cid_name = argv[3] ? argv[3] : "anonymous";
+ forwarded_by = argv[4];
user = box;
}
}
+ if (forwarded_by) {
+ switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "Forwarded-By", forwarded_by);
+ }
switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "domain", domain);
switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "purpose", "publish-vm");
if (switch_xml_locate_user_in_domain(uname, x_domain, &ux, NULL) == SWITCH_STATUS_SUCCESS) {
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ux, domain, path, 0, "B", my_params, pool, cid_name, cid_num, SWITCH_TRUE);
+ status = deliver_vm(profile, ux, domain, path, 0, "B", my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
switch_event_destroy(&my_params);
}
continue;
}
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, SWITCH_TRUE);
+ status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
switch_event_destroy(&my_params);
}
}
}
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, SWITCH_TRUE);
+ status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
switch_event_destroy(&my_params);
}
}
if ((status = switch_xml_locate_user_in_domain(user, x_domain, &ut, &x_group)) == SWITCH_STATUS_SUCCESS) {
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
- status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, SWITCH_TRUE);
+ status = deliver_vm(profile, ut, domain, path, 0, "B", my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
switch_event_destroy(&my_params);
} else {
status = SWITCH_STATUS_FALSE;
if (x_domain_root) {
switch_channel_get_variables(channel, &vars);
status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars,
- switch_core_session_get_pool(session), caller_id_name, caller_id_number, SWITCH_FALSE);
+ switch_core_session_get_pool(session), caller_id_name, caller_id_number, NULL, SWITCH_FALSE);
switch_event_destroy(&vars);
if (status == SWITCH_STATUS_SUCCESS) {
if ((vm_cc = switch_channel_get_variable(channel, "vm_cc"))) {
- char *cmd = switch_core_session_sprintf(session, "%s %s %s %s", vm_cc, file_path, caller_id_number, caller_id_name);
+ char *cmd = switch_core_session_sprintf(session, "%s %s %s %s %s@%s", vm_cc, file_path, caller_id_number, caller_id_name, id, domain_name);
+
if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Sent Carbon Copy to %s\n", vm_cc);
} else {