[Asterisk-code-review] app voicemail: Cannot set fromstring on a per-mailbox basis (asterisk[13])
Daniel Journo
asteriskteam at digium.com
Wed Mar 8 08:57:29 CST 2017
Daniel Journo has uploaded a new change for review. ( https://gerrit.asterisk.org/5141 )
Change subject: app_voicemail: Cannot set fromstring on a per-mailbox basis
......................................................................
app_voicemail: Cannot set fromstring on a per-mailbox basis
* apps/app_voicemail.c fromstring field added to mailbox which will
override the global fromstring if set.
ASTERISK-24562
Change-Id: I5e90e3a1ec2b2d5340b49a0db825e4bbb158b2fe
---
M apps/app_voicemail.c
M configs/samples/voicemail.conf.sample
2 files changed, 18 insertions(+), 5 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/5141/1
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 6089779..ec1a4ca 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -805,6 +805,7 @@
char *emailbody; /*!< E-mail body */
char pager[80]; /*!< E-mail address to pager (no attachment) */
char serveremail[80]; /*!< From: Mail address */
+ char fromstring[100]; /*!< From: Username */
char language[MAX_LANGUAGE]; /*!< Config: Language setting */
char zonetag[80]; /*!< Time zone */
char locale[20]; /*!< The locale (for presentation of date/time) */
@@ -1310,6 +1311,8 @@
ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
} else if (!strcasecmp(var, "serveremail")) {
ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
+ } else if (!strcasecmp(var, "fromstring")) {
+ ast_copy_string(vmu->fromstring, value, sizeof(vmu->fromstring));
} else if (!strcasecmp(var, "emailbody")) {
ast_free(vmu->emailbody);
vmu->emailbody = ast_strdup(substitute_escapes(value));
@@ -5116,12 +5119,13 @@
/* Set date format for voicemail mail */
ast_strftime_locale(date, sizeof(date), emaildateformat, &tm, S_OR(vmu->locale, NULL));
- if (!ast_strlen_zero(fromstring)) {
+ if (!ast_strlen_zero(fromstring) || !ast_strlen_zero(vmu->fromstring)) {
struct ast_channel *ast;
+ char *e_fromstring = !ast_strlen_zero(vmu->fromstring) ? vmu->fromstring : fromstring;
if ((ast = ast_dummy_channel_alloc())) {
char *ptr;
prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, enc_cidnum, enc_cidname, dur, date, category, flag);
- ast_str_substitute_variables(&str1, 0, ast, fromstring);
+ ast_str_substitute_variables(&str1, 0, ast, e_fromstring);
if (check_mime(ast_str_buffer(str1))) {
first_line = 1;
@@ -12234,7 +12238,7 @@
struct ast_vm_user *vmu;
/* language parameter seems to only be used for display in manager action */
static const char options_string[] = "attach=yes|attachfmt=wav49|"
- "serveremail=someguy at digium.com|tz=central|delete=yes|saycid=yes|"
+ "serveremail=someguy at digium.com|fromstring=Voicemail System|tz=central|delete=yes|saycid=yes|"
"sendvoicemail=yes|review=yes|tempgreetwarn=yes|messagewrap=yes|operator=yes|"
"envelope=yes|moveheard=yes|sayduration=yes|saydurationm=5|forcename=yes|"
"forcegreetings=yes|callback=somecontext|dialout=somecontext2|"
@@ -12273,6 +12277,10 @@
}
if (strcasecmp(vmu->attachfmt, "wav49")) {
ast_test_status_update(test, "Parse failure for attachftm option\n");
+ res = 1;
+ }
+ if (strcasecmp(vmu->fromstring, "Voicemail System")) {
+ ast_test_status_update(test, "Parse failure for fromstring option\n");
res = 1;
}
if (strcasecmp(vmu->serveremail, "someguy at digium.com")) {
@@ -12834,6 +12842,7 @@
USER(ast_vm_user, emailbody, AST_DATA_STRING) \
USER(ast_vm_user, pager, AST_DATA_STRING) \
USER(ast_vm_user, serveremail, AST_DATA_STRING) \
+ USER(ast_vm_user, fromstring, AST_DATA_STRING) \
USER(ast_vm_user, language, AST_DATA_STRING) \
USER(ast_vm_user, zonetag, AST_DATA_STRING) \
USER(ast_vm_user, callback, AST_DATA_STRING) \
@@ -12861,6 +12870,7 @@
USER(ast_vm_user, emailbody, AST_DATA_STRING) \
USER(ast_vm_user, pager, AST_DATA_STRING) \
USER(ast_vm_user, serveremail, AST_DATA_STRING) \
+ USER(ast_vm_user, fromstring, AST_DATA_STRING) \
USER(ast_vm_user, language, AST_DATA_STRING) \
USER(ast_vm_user, zonetag, AST_DATA_STRING) \
USER(ast_vm_user, callback, AST_DATA_STRING) \
@@ -13250,6 +13260,7 @@
"Email: %s\r\n"
"Pager: %s\r\n"
"ServerEmail: %s\r\n"
+ "FromString: %s\r\n"
"MailCommand: %s\r\n"
"Language: %s\r\n"
"TimeZone: %s\r\n"
@@ -13284,6 +13295,7 @@
vmu->email,
vmu->pager,
ast_strlen_zero(vmu->serveremail) ? serveremail : vmu->serveremail,
+ ast_strlen_zero(vmu->fromstring) ? fromstring : vmu->fromstring,
mailcmd,
vmu->language,
vmu->zonetag,
diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample
index 1c91ffb..ac63c1d 100644
--- a/configs/samples/voicemail.conf.sample
+++ b/configs/samples/voicemail.conf.sample
@@ -239,7 +239,8 @@
;
; Advanced options example is extension 4069
; NOTE: All options can be expressed globally in the general section, and
-; overridden in the per-mailbox settings, unless listed otherwise.
+; overridden in the per-mailbox settings, unless listed otherwise.
+;
;
; tz=central ; Timezone from zonemessages below. Irrelevant if envelope=no.
; locale=de_DE.UTF-8 ; set the locale for generation of the date/time strings (make
@@ -439,7 +440,7 @@
; Note: The rest of the system must reference mailboxes defined here as mailbox at default.
1234 => 4242,Example Mailbox,root at localhost
-;4200 => 9855,Mark Spencer,markster at linux-support.net,mypager at digium.com,attach=no|serveremail=myaddy at digium.com|tz=central|maxmsg=10
+;4200 => 9855,Mark Spencer,markster at linux-support.net,mypager at digium.com,attach=no|serveremail=myaddy at digium.com|fromstring=MySystem|tz=central|maxmsg=10
;4300 => 3456,Ben Rigas,ben at american-computer.net
;4310 => -5432,Sales,sales at marko.net
;4069 => 6522,Matt Brooks,matt at marko.net,,|tz=central|attach=yes|saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes|envelope=yes|moveheard=yes|sayduration=yes|saydurationm=1
--
To view, visit https://gerrit.asterisk.org/5141
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e90e3a1ec2b2d5340b49a0db825e4bbb158b2fe
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Daniel Journo <dan at keshercommunications.com>
More information about the asterisk-code-review
mailing list