app_voicemail: Allow preventing mark messages as urgent.

This adds an option to allow preventing callers from leaving
messages marked as 'urgent'.

Resolves: #619

UserNote: The leaveurgent mailbox option can now be used to
control whether callers may leave messages marked as 'Urgent'.
This commit is contained in:
Naveen Albert 2024-02-24 15:54:57 -05:00 committed by asterisk-org-access-app[bot]
parent 6291ddaf90
commit b5850941b1
2 changed files with 22 additions and 4 deletions

View File

@ -688,6 +688,7 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
#define VM_MESSAGEWRAP (1 << 17) /*!< Wrap around from the last message to the first, and vice-versa */
#define VM_FWDURGAUTO (1 << 18) /*!< Autoset of Urgent flag on forwarded Urgent messages set globally */
#define VM_EMAIL_EXT_RECS (1 << 19) /*!< Send voicemail emails when an external recording is added to a mailbox */
#define VM_MARK_URGENT (1 << 20) /*!< After recording, permit the caller to mark the message as urgent */
#define ERROR_LOCK_PATH -100
#define ERROR_MAX_MSGS -101
#define OPERATOR_EXIT 300
@ -1426,6 +1427,8 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
ast_set2_flag(vmu, ast_true(value), VM_SVMAIL);
} else if (!strcasecmp(var, "review")){
ast_set2_flag(vmu, ast_true(value), VM_REVIEW);
} else if (!strcasecmp(var, "leaveurgent")){
ast_set2_flag(vmu, ast_true(value), VM_MARK_URGENT);
} else if (!strcasecmp(var, "tempgreetwarn")){
ast_set2_flag(vmu, ast_true(value), VM_TEMPGREETWARN);
} else if (!strcasecmp(var, "messagewrap")){
@ -12921,7 +12924,7 @@ AST_TEST_DEFINE(test_voicemail_vmuser)
/* language parameter seems to only be used for display in manager action */
static const char options_string[] = "attach=yes|attachfmt=wav49|"
"serveremail=someguy@digium.com|fromstring=Voicemail System|tz=central|delete=yes|saycid=yes|"
"sendvoicemail=yes|review=yes|tempgreetwarn=yes|messagewrap=yes|operator=yes|"
"sendvoicemail=yes|review=yes|tempgreetwarn=yes|messagewrap=yes|operator=yes|leaveurgent=yes|"
"envelope=yes|moveheard=yes|sayduration=yes|saydurationm=5|forcename=yes|"
"forcegreetings=yes|callback=somecontext|dialout=somecontext2|"
"exitcontext=somecontext3|minsecs=10|maxsecs=100|nextaftercmd=yes|"
@ -12997,6 +13000,10 @@ AST_TEST_DEFINE(test_voicemail_vmuser)
ast_test_status_update(test, "Parse failure for review option\n");
res = 1;
}
if (!ast_test_flag(vmu, VM_MARK_URGENT)) {
ast_test_status_update(test, "Parse failure for leaveurgent option\n");
res = 1;
}
if (!ast_test_flag(vmu, VM_TEMPGREETWARN)) {
ast_test_status_update(test, "Parse failure for tempgreetwarm option\n");
res = 1;
@ -13727,6 +13734,7 @@ static int append_vmu_info_astman(
"DeleteMessage: %s\r\n"
"VolumeGain: %.2f\r\n"
"CanReview: %s\r\n"
"CanMarkUrgent: %s\r\n"
"CallOperator: %s\r\n"
"MaxMessageCount: %d\r\n"
"MaxMessageLength: %d\r\n"
@ -13764,6 +13772,7 @@ static int append_vmu_info_astman(
ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
vmu->volgain,
ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
ast_test_flag(vmu, VM_MARK_URGENT) ? "Yes" : "No",
ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
vmu->maxmsg,
vmu->maxsecs,
@ -14728,6 +14737,14 @@ static int actual_load_config(int reload, struct ast_config *cfg, struct ast_con
}
ast_set2_flag((&globalflags), ast_true(val), VM_REVIEW);
if (!(val = ast_variable_retrieve(cfg, "general", "leaveurgent"))){
val = "yes";
} else if (ast_false(val)) {
ast_debug(1, "VM leave urgent messages disabled globally\n");
val = "no";
}
ast_set2_flag((&globalflags), ast_true(val), VM_MARK_URGENT);
/* Temporary greeting reminder */
if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n");
@ -16295,7 +16312,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
}
break;
case '4':
if (outsidecaller) { /* only mark vm messages */
if (outsidecaller && ast_test_flag(vmu, VM_MARK_URGENT)) { /* only mark vm messages */
/* Mark Urgent */
if ((flag && ast_strlen_zero(flag)) || (!ast_strlen_zero(flag) && strcmp(flag, "Urgent"))) {
ast_verb(3, "marking message as Urgent\n");
@ -16372,7 +16389,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re
return cmd;
if (msg_exists) {
cmd = ast_play_and_wait(chan, "vm-review");
if (!cmd && outsidecaller) {
if (!cmd && outsidecaller && ast_test_flag(vmu, VM_MARK_URGENT)) {
if ((flag && ast_strlen_zero(flag)) || (!ast_strlen_zero(flag) && strcmp(flag, "Urgent"))) {
cmd = ast_play_and_wait(chan, "vm-review-urgent");
} else if (flag) {

View File

@ -293,7 +293,8 @@ sendvoicemail=yes ; Allow the user to compose and send a voicemail while inside
; if not listed, calling the sender back will not be permitted
; exitcontext=fromvm ; Context to go to on user exit such as * or 0
; The default is the current context.
; review=yes ; Allow sender to review/rerecord their message before saving it [OFF by default
; review=yes ; Allow sender to review/rerecord their message before saving it [OFF by default]
; leaveurgent=yes ; Allow senders to leave messages that are marked as 'Urgent' [ON by default]
; operator=yes ; Allow sender to hit 0 before/after/during leaving a voicemail to
; reach an operator. This option REQUIRES an 'o' extension in the
; same context (or in exitcontext, if set), as that is where the