diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index e89bda47f1..732059aff4 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -2687,23 +2687,29 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t if ((domain = strchr(user, '@'))) { *domain++ = '\0'; - } else { - domain = user; - } - if ((profile_name = strchr(domain, '@'))) { - *profile_name++ = '\0'; - } else { - profile_name = domain; + if ((profile_name = strchr(domain, '@'))) { + *profile_name++ = '\0'; + } else { + profile_name = domain; + } } if (switch_stristr("group=", user)) { user += 6; isgroup++; - } else if (user == domain) { + } else if (switch_stristr("domain=", user)) { + user += 7; + domain = user; + profile_name = domain; isall++; } + if (zstr(domain)) { + domain = switch_core_get_variable("domain"); + profile_name = domain; + } + if (!(user && domain)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid syntax [%s][%s]\n", switch_str_nil(user), switch_str_nil(domain)); status = SWITCH_STATUS_FALSE; @@ -2747,6 +2753,7 @@ static switch_status_t voicemail_inject(const char *data, switch_core_session_t switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate domain %s\n", domain); status = SWITCH_STATUS_FALSE; switch_event_destroy(&my_params); + profile_rwunlock(profile); goto end; } @@ -3962,7 +3969,7 @@ static void do_web(vm_profile_t *profile, const char *user_in, const char *domai } } -#define VM_INJECT_USAGE "[group=] [] []" +#define VM_INJECT_USAGE "[group=[@domain]|domain=|[@]] [] []" SWITCH_STANDARD_API(voicemail_inject_api_function) { if (voicemail_inject(cmd, session) == SWITCH_STATUS_SUCCESS) {