From d95432aad31517eaf9284ad883a6c2b03c6abcf6 Mon Sep 17 00:00:00 2001 From: Matt O'Gorman Date: Mon, 15 Jan 2007 21:08:07 +0000 Subject: [PATCH] Merged revisions 50946 via svnmerge from https://svn.digium.com/svn/asterisk/branches/1.2 ........ r50946 | mogorman | 2007-01-15 14:44:53 -0600 (Mon, 15 Jan 2007) | 4 lines Solves issue with forwarding voicemails from folders other than inbox. patch by anthonyl. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@50957 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index ea294bc3c6..d51b176feb 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2646,7 +2646,7 @@ static int messagecount(const char *context, const char *mailbox, const char *fo #endif #ifndef IMAP_STORAGE /* copy message only used by file storage */ -static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt) +static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt, char *dir) { char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX]; const char *frombox = mbox(imbox); @@ -2655,8 +2655,12 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context); create_dirpath(todir, sizeof(todir), recip->context, recip->mailbox, "INBOX"); + + if (!dir) + make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox); + else + ast_copy_string(fromdir, dir, sizeof(fromdir)); - make_dir(fromdir, sizeof(fromdir), vmu->context, vmu->mailbox, frombox); make_file(frompath, sizeof(frompath), fromdir, msgnum); if (vm_lock_path(todir)) @@ -3162,7 +3166,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ context++; } if ((recip = find_user(&recipu, context, exten))) { - copy_message(chan, vmu, 0, msgnum, duration, recip, fmt); + copy_message(chan, vmu, 0, msgnum, duration, recip, fmt, dir); free_user(recip); } } @@ -4162,7 +4166,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st /* NULL category for IMAP storage */ sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL); #else - copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt); + copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir); #endif saved_messages++; AST_LIST_REMOVE_CURRENT(&extensions, list);