From: Jonathan Rose Date: Wed, 16 Nov 2011 14:56:03 +0000 (+0000) Subject: Guarantee messages go into the right folders with multiple recipients X-Git-Tag: 11.0.0-beta1~922 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d67b1b37878a799be9716de2ed1087a5687ac58;p=thirdparty%2Fasterisk.git Guarantee messages go into the right folders with multiple recipients Before, using the U flag in Voicemail with multiple recipients would put urgent messages in the INBOX folder for all users past the first thanks to a bug with the message copying function. This would also cause messages to fail to be sent if the INBOX directory hadn't been created for that mailbox yet. (closes issue ASTERISK-18245) Reported by: Matt Jordan (closes issue ASTERISK-18246) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/1589/ ........ Merged revisions 345487 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 345488 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@345489 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 1e2942b837..be604f0c18 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -5303,24 +5303,27 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i { char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX]; const char *frombox = mbox(vmu, imbox); + const char *userfolder; int recipmsgnum; int res = 0; ast_log(AST_LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context); if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) { /* If urgent, copy to Urgent folder */ - create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "Urgent"); + userfolder = "Urgent"; } else { - create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); + userfolder = "INBOX"; } - + + create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, userfolder); + if (!dir) make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox); else ast_copy_string(fromdir, dir, sizeof(fromdir)); make_file(frompath, sizeof(frompath), fromdir, msgnum); - make_dir(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); + make_dir(todir, sizeof(todir), recip->context, recip->mailbox, userfolder); if (vm_lock_path(todir)) return ERROR_LOCK_PATH; @@ -6037,7 +6040,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ while (tmpptr) { struct ast_vm_user recipu, *recip; char *exten, *cntx; - + exten = strsep(&tmpptr, "&"); cntx = strchr(exten, '@'); if (cntx) {