Skip to content
Snippets Groups Projects
Commit 5ce4ad80 authored by Jason Parker's avatar Jason Parker
Browse files

app_voicemail: Add the ability to specify multiple email addresses.

ASTERISK-24045
Reported by: Jacob Barber
Review: https://reviewboard.asterisk.org/r/3833/
........

Merged revisions 420577 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 91f7b661
No related branches found
No related tags found
No related merge requests found
...@@ -210,6 +210,9 @@ VoiceMail ...@@ -210,6 +210,9 @@ VoiceMail
- jb-wa: article wa - jb-wa: article wa
- jb-wo: article wo - jb-wo: article wo
* Add the ability to specify multiple email addresses in configuration,
separated by a |.
res_config_pgsql res_config_pgsql
------------------ ------------------
* Added the ability to support PostgreSQL application_name on connections. * Added the ability to support PostgreSQL application_name on connections.
......
...@@ -795,7 +795,7 @@ struct ast_vm_user { ...@@ -795,7 +795,7 @@ struct ast_vm_user {
char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */ char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox id, unique within vm context */
char password[80]; /*!< Secret pin code, numbers only */ char password[80]; /*!< Secret pin code, numbers only */
char fullname[80]; /*!< Full name, for directory app */ char fullname[80]; /*!< Full name, for directory app */
char email[80]; /*!< E-mail address */ char *email; /*!< E-mail address */
char *emailsubject; /*!< E-mail subject */ char *emailsubject; /*!< E-mail subject */
char *emailbody; /*!< E-mail body */ char *emailbody; /*!< E-mail body */
char pager[80]; /*!< E-mail address to pager (no attachment) */ char pager[80]; /*!< E-mail address to pager (no attachment) */
...@@ -1269,6 +1269,8 @@ static void populate_defaults(struct ast_vm_user *vmu) ...@@ -1269,6 +1269,8 @@ static void populate_defaults(struct ast_vm_user *vmu)
vmu->maxdeletedmsg = maxdeletedmsg; vmu->maxdeletedmsg = maxdeletedmsg;
} }
vmu->volgain = volgain; vmu->volgain = volgain;
ast_free(vmu->email);
vmu->email = NULL;
ast_free(vmu->emailsubject); ast_free(vmu->emailsubject);
vmu->emailsubject = NULL; vmu->emailsubject = NULL;
ast_free(vmu->emailbody); ast_free(vmu->emailbody);
...@@ -1580,7 +1582,8 @@ static void apply_options_full(struct ast_vm_user *retval, struct ast_variable * ...@@ -1580,7 +1582,8 @@ static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *
} else if (!strcasecmp(var->name, "pager")) { } else if (!strcasecmp(var->name, "pager")) {
ast_copy_string(retval->pager, var->value, sizeof(retval->pager)); ast_copy_string(retval->pager, var->value, sizeof(retval->pager));
} else if (!strcasecmp(var->name, "email")) { } else if (!strcasecmp(var->name, "email")) {
ast_copy_string(retval->email, var->value, sizeof(retval->email)); ast_free(retval->email);
retval->email = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "fullname")) { } else if (!strcasecmp(var->name, "fullname")) {
ast_copy_string(retval->fullname, var->value, sizeof(retval->fullname)); ast_copy_string(retval->fullname, var->value, sizeof(retval->fullname));
} else if (!strcasecmp(var->name, "context")) { } else if (!strcasecmp(var->name, "context")) {
...@@ -1717,6 +1720,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *contex ...@@ -1717,6 +1720,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *contex
if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) { if ((vmu = (ivm ? ivm : ast_malloc(sizeof(*vmu))))) {
*vmu = *cur; *vmu = *cur;
if (!ivm) { if (!ivm) {
vmu->email = ast_strdup(cur->email);
vmu->emailbody = ast_strdup(cur->emailbody); vmu->emailbody = ast_strdup(cur->emailbody);
vmu->emailsubject = ast_strdup(cur->emailsubject); vmu->emailsubject = ast_strdup(cur->emailsubject);
} }
...@@ -1999,6 +2003,9 @@ static void free_user(struct ast_vm_user *vmu) ...@@ -1999,6 +2003,9 @@ static void free_user(struct ast_vm_user *vmu)
{ {
if (ast_test_flag(vmu, VM_ALLOCED)) { if (ast_test_flag(vmu, VM_ALLOCED)) {
   
ast_free(vmu->email);
vmu->email = NULL;
ast_free(vmu->emailbody); ast_free(vmu->emailbody);
vmu->emailbody = NULL; vmu->emailbody = NULL;
   
...@@ -2629,7 +2636,7 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char ...@@ -2629,7 +2636,7 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
* of this function, we will revert back to an empty string if tempcopy * of this function, we will revert back to an empty string if tempcopy
* is 1. * is 1.
*/ */
ast_copy_string(vmu->email, vmu->imapuser, sizeof(vmu->email)); vmu->email = ast_strdup(vmu->imapuser);
tempcopy = 1; tempcopy = 1;
} }
   
...@@ -2641,8 +2648,10 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char ...@@ -2641,8 +2648,10 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
command hangs. */ command hangs. */
if (!(p = vm_mkftemp(tmp))) { if (!(p = vm_mkftemp(tmp))) {
ast_log(AST_LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn); ast_log(AST_LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
if (tempcopy) if (tempcopy) {
*(vmu->email) = '\0'; ast_free(vmu->email);
vmu->email = NULL;
}
return -1; return -1;
} }
   
...@@ -4964,6 +4973,9 @@ static void make_email_file(FILE *p, ...@@ -4964,6 +4973,9 @@ static void make_email_file(FILE *p,
struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16); struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16);
char *greeting_attachment; char *greeting_attachment;
char filename[256]; char filename[256];
int first_line;
char *emailsbuf;
char *email;
   
if (!str1 || !str2) { if (!str1 || !str2) {
ast_free(str1); ast_free(str1);
...@@ -5005,7 +5017,7 @@ static void make_email_file(FILE *p, ...@@ -5005,7 +5017,7 @@ static void make_email_file(FILE *p,
ast_str_substitute_variables(&str1, 0, ast, fromstring); ast_str_substitute_variables(&str1, 0, ast, fromstring);
   
if (check_mime(ast_str_buffer(str1))) { if (check_mime(ast_str_buffer(str1))) {
int first_line = 1; first_line = 1;
ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("From: "), strlen(who) + 3); ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("From: "), strlen(who) + 3);
while ((ptr = strchr(ast_str_buffer(str2), ' '))) { while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
*ptr = '\0'; *ptr = '\0';
...@@ -5026,20 +5038,25 @@ static void make_email_file(FILE *p, ...@@ -5026,20 +5038,25 @@ static void make_email_file(FILE *p,
fprintf(p, "From: Asterisk PBX <%s>" ENDL, who); fprintf(p, "From: Asterisk PBX <%s>" ENDL, who);
} }
   
if (check_mime(vmu->fullname)) { emailsbuf = ast_strdupa(vmu->email);
int first_line = 1; fprintf(p, "To:");
char *ptr; first_line = 1;
ast_str_encode_mime(&str2, 0, vmu->fullname, strlen("To: "), strlen(vmu->email) + 3); while ((email = strsep(&emailsbuf, "|"))) {
while ((ptr = strchr(ast_str_buffer(str2), ' '))) { char *next = strchr(S_OR(emailsbuf, ""), '|');
*ptr = '\0'; if (check_mime(vmu->fullname)) {
fprintf(p, "%s %s" ENDL, first_line ? "To:" : "", ast_str_buffer(str2)); char *ptr;
first_line = 0; ast_str_encode_mime(&str2, 0, vmu->fullname, first_line ? strlen("To: ") : 0, strlen(email) + 3 + (next ? strlen(",") : 0));
/* Substring is smaller, so this will never grow */ while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
ast_str_set(&str2, 0, "%s", ptr + 1); *ptr = '\0';
fprintf(p, " %s" ENDL, ast_str_buffer(str2));
/* Substring is smaller, so this will never grow */
ast_str_set(&str2, 0, "%s", ptr + 1);
}
fprintf(p, " %s <%s>%s" ENDL, ast_str_buffer(str2), email, next ? "," : "");
} else {
fprintf(p, " %s <%s>%s" ENDL, ast_str_quote(&str2, 0, vmu->fullname), email, next ? "," : "");
} }
fprintf(p, "%s %s <%s>" ENDL, first_line ? "To:" : "", ast_str_buffer(str2), vmu->email); first_line = 0;
} else {
fprintf(p, "To: %s <%s>" ENDL, ast_str_quote(&str2, 0, vmu->fullname), vmu->email);
} }
   
if (!ast_strlen_zero(emailsubject) || !ast_strlen_zero(vmu->emailsubject)) { if (!ast_strlen_zero(emailsubject) || !ast_strlen_zero(vmu->emailsubject)) {
...@@ -5049,7 +5066,7 @@ static void make_email_file(FILE *p, ...@@ -5049,7 +5066,7 @@ static void make_email_file(FILE *p,
prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag); prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, category, flag);
ast_str_substitute_variables(&str1, 0, ast, e_subj); ast_str_substitute_variables(&str1, 0, ast, e_subj);
if (check_mime(ast_str_buffer(str1))) { if (check_mime(ast_str_buffer(str1))) {
int first_line = 1; first_line = 1;
char *ptr; char *ptr;
ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("Subject: "), 0); ast_str_encode_mime(&str2, 0, ast_str_buffer(str1), strlen("Subject: "), 0);
while ((ptr = strchr(ast_str_buffer(str2), ' '))) { while ((ptr = strchr(ast_str_buffer(str2), ' '))) {
...@@ -12011,7 +12028,7 @@ static int append_mailbox(const char *context, const char *box, const char *data ...@@ -12011,7 +12028,7 @@ static int append_mailbox(const char *context, const char *box, const char *data
ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname)); ast_copy_string(vmu->fullname, s, sizeof(vmu->fullname));
} }
if (stringp && (s = strsep(&stringp, ","))) { if (stringp && (s = strsep(&stringp, ","))) {
ast_copy_string(vmu->email, s, sizeof(vmu->email)); vmu->email = ast_strdup(s);
} }
if (stringp && (s = strsep(&stringp, ","))) { if (stringp && (s = strsep(&stringp, ","))) {
ast_copy_string(vmu->pager, s, sizeof(vmu->pager)); ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
...@@ -14342,7 +14359,7 @@ AST_TEST_DEFINE(test_voicemail_notify_endl) ...@@ -14342,7 +14359,7 @@ AST_TEST_DEFINE(test_voicemail_notify_endl)
} }
   
populate_defaults(vmu); populate_defaults(vmu);
ast_copy_string(vmu->email, "test2@example.net", sizeof(vmu->email)); vmu->email = ast_strdup("test2@example.net");
#ifdef IMAP_STORAGE #ifdef IMAP_STORAGE
/* TODO When we set up the IMAP server test, we'll need to have credentials for the VMU structure added here */ /* TODO When we set up the IMAP server test, we'll need to have credentials for the VMU structure added here */
#endif #endif
......
...@@ -232,10 +232,10 @@ pagerdateformat=%A, %B %d, %Y at %r ...@@ -232,10 +232,10 @@ pagerdateformat=%A, %B %d, %Y at %r
; ;
; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options> ; Each mailbox is listed in the form <mailbox>=<password>,<name>,<email>,<pager_email>,<options>
; if the e-mail is specified, a message will be sent when a message is ; If email is specified, a message will be sent when a voicemail is received, to
; received, to the given mailbox. If pager is specified, a message will be ; the given mailbox, for each address listed (separated by |, ex. alice@foo.com|bob@foo.com).
; sent there as well. If the password is prefixed by '-', then it is ; If pager is specified, a message will be sent there as well. If the password
; considered to be unchangeable. ; is prefixed by '-', then it is considered to be unchangeable.
; ;
; Advanced options example is extension 4069 ; Advanced options example is extension 4069
; NOTE: All options can be expressed globally in the general section, and ; NOTE: All options can be expressed globally in the general section, and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment