diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 55afc074d3099ca290b960c58b61dc1ca6414d36..1e2942b837cfb36de2ce5facfb25bceaf2061fa1 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -9193,8 +9193,37 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY); } - /* First, have the user change their password - so they won't get here again */ + /* If forcename is set, have the user record their name */ + if (ast_test_flag(vmu, VM_FORCENAME)) { + snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); + if (ast_fileexists(prefile, NULL, NULL) < 1) { + cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + } + } + + /* If forcegreetings is set, have the user record their greetings */ + if (ast_test_flag(vmu, VM_FORCEGREET)) { + snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); + if (ast_fileexists(prefile, NULL, NULL) < 1) { + cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + } + + snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); + if (ast_fileexists(prefile, NULL, NULL) < 1) { + cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); + if (cmd < 0 || cmd == 't' || cmd == '#') + return cmd; + } + } + + /* + * Change the password last since new users will be able to skip over any steps this one comes before + * by hanging up and calling back to voicemail main since the password is used to verify new user status. + */ for (;;) { newpassword[1] = '\0'; newpassword[0] = cmd = ast_play_and_wait(chan, vm_newpassword); @@ -9238,33 +9267,6 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct ast_debug(1, "User %s set password to %s of length %d\n", vms->username, newpassword, (int) strlen(newpassword)); cmd = ast_play_and_wait(chan, vm_passchanged); - /* If forcename is set, have the user record their name */ - if (ast_test_flag(vmu, VM_FORCENAME)) { - snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); - if (ast_fileexists(prefile, NULL, NULL) < 1) { - cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); - if (cmd < 0 || cmd == 't' || cmd == '#') - return cmd; - } - } - - /* If forcegreetings is set, have the user record their greetings */ - if (ast_test_flag(vmu, VM_FORCEGREET)) { - snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); - if (ast_fileexists(prefile, NULL, NULL) < 1) { - cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); - if (cmd < 0 || cmd == 't' || cmd == '#') - return cmd; - } - - snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); - if (ast_fileexists(prefile, NULL, NULL) < 1) { - cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, NULL, record_gain, vms, NULL); - if (cmd < 0 || cmd == 't' || cmd == '#') - return cmd; - } - } - return cmd; }