[mod_voicemail] Fix API, allow greeting deletion (Issue #977)

This commit is contained in:
Martin Paterson 2020-12-16 11:36:43 +00:00
parent 8045c96458
commit 4b30a81042
1 changed files with 5 additions and 1 deletions

View File

@ -5104,7 +5104,7 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function)
if (argv[4]) if (argv[4])
file_path = argv[4]; file_path = argv[4];
if (!profile_name || !domain || !id || !slot) { if (!profile_name || !domain || !id || slot == -1) {
stream->write_function(stream, "-ERR Missing Arguments\n"); stream->write_function(stream, "-ERR Missing Arguments\n");
goto done; goto done;
} }
@ -5112,6 +5112,10 @@ SWITCH_STANDARD_API(vm_fsdb_pref_greeting_set_function)
if (!(profile = get_profile(profile_name))) { if (!(profile = get_profile(profile_name))) {
stream->write_function(stream, "-ERR Profile not found\n"); stream->write_function(stream, "-ERR Profile not found\n");
goto done; goto done;
} if (slot == 0) {
sql = switch_mprintf("UPDATE voicemail_prefs SET greeting_path = NULL WHERE username = '%q' AND domain = '%q'", id, domain);
vm_execute_sql(profile, sql, profile->mutex);
switch_safe_free(sql);
} else { } else {
char *dir_path = switch_core_sprintf(pool, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, char *dir_path = switch_core_sprintf(pool, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
SWITCH_PATH_SEPARATOR, SWITCH_PATH_SEPARATOR,