mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
app_voicemail: Fix missing email in msg_create_from_file.
msg_create_from_file currently does not dispatch emails, which means that applications using this function, such as MixMonitor, will not trigger notifications to users (only AMI events are sent our currently). This is inconsistent with other ways users can receive voicemail. This is fixed by adding an option that attempts to send an email and falling back to just the notifications as done now if that fails. The existing behavior remains the default. ASTERISK-30283 #close Change-Id: I597cbb9cf971a18d8776172b26ab187dc096a5c7
This commit is contained in:
committed by
Friendly Automation
parent
52ed64e38a
commit
9e14523ca3
@@ -570,6 +570,7 @@ static AST_LIST_HEAD_STATIC(vmstates, vmstate);
|
||||
#define VM_MOVEHEARD (1 << 16) /*!< Move a "heard" message to Old after listening to it */
|
||||
#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 ERROR_LOCK_PATH -100
|
||||
#define ERROR_MAX_MSGS -101
|
||||
#define OPERATOR_EXIT 300
|
||||
@@ -1258,6 +1259,8 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v
|
||||
ast_set2_flag(vmu, ast_true(value), VM_ATTACH);
|
||||
} else if (!strcasecmp(var, "attachfmt")) {
|
||||
ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
|
||||
} else if (!strcasecmp(var, "attachextrecs")) {
|
||||
ast_set2_flag(vmu, ast_true(value), VM_EMAIL_EXT_RECS);
|
||||
} else if (!strcasecmp(var, "serveremail")) {
|
||||
ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
|
||||
} else if (!strcasecmp(var, "fromstring")) {
|
||||
@@ -6418,6 +6421,12 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
|
||||
* to do both with one line and is also safe to use with file storage mode. Also, if we are using ODBC, now is a good
|
||||
* time to create the voicemail database entry. */
|
||||
if (ast_fileexists(destination, NULL, NULL) > 0) {
|
||||
struct ast_channel *chan = NULL;
|
||||
char fmt[80];
|
||||
char clid[80];
|
||||
char cidnum[80], cidname[80];
|
||||
int send_email;
|
||||
|
||||
if (ast_check_realtime("voicemail_data")) {
|
||||
get_date(date, sizeof(date));
|
||||
ast_store_realtime("voicemail_data",
|
||||
@@ -6437,7 +6446,27 @@ static int msg_create_from_file(struct ast_vm_recording_data *recdata)
|
||||
}
|
||||
|
||||
STORE(dir, recipient->mailbox, recipient->context, msgnum, NULL, recipient, fmt, 0, vms, "", msg_id);
|
||||
notify_new_state(recipient);
|
||||
|
||||
send_email = ast_test_flag(recipient, VM_EMAIL_EXT_RECS);
|
||||
|
||||
if (send_email) {
|
||||
/* Send an email if possible, fall back to just notifications if not. */
|
||||
ast_copy_string(fmt, recdata->recording_ext, sizeof(fmt));
|
||||
ast_copy_string(clid, recdata->call_callerid, sizeof(clid));
|
||||
ast_callerid_split(clid, cidname, sizeof(cidname), cidnum, sizeof(cidnum));
|
||||
|
||||
/* recdata->call_callerchan itself no longer exists, so we can't use the real channel. Use a dummy one. */
|
||||
chan = ast_dummy_channel_alloc();
|
||||
}
|
||||
if (chan) {
|
||||
notify_new_message(chan, recipient, NULL, msgnum, duration, fmt, cidnum, cidname, "");
|
||||
ast_channel_unref(chan);
|
||||
} else {
|
||||
if (send_email) { /* We tried and failed. */
|
||||
ast_log(LOG_WARNING, "Failed to allocate dummy channel, email will not be sent\n");
|
||||
}
|
||||
notify_new_state(recipient);
|
||||
}
|
||||
}
|
||||
|
||||
free_user(recipient);
|
||||
|
Reference in New Issue
Block a user