Summary:ASTERISK-24927: app_voicemail (IMAP support) function save_to_folder: creates wrong folder
Reporter:Alexei Gradinari (alexei gradinari)Labels:
Date Opened:2015-03-30 16:07:48Date Closed:2016-09-23 14:16:31
Versions:13.2.0 Frequency of
is related toASTERISK-24266 imapparentfolder Ignored - saving messages to another folder fails whether it exists or not
Description:If try to move message to Cust1 (number 5) the function save_to_folder tries to create Greeting folder instead of Cust1.

The function save_to_folder calls imap_mailbox_name to get mailbox name by box id:
       imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1);
then tries to create IMAP folder:
       if (mail_create(vms->mailstream, mailbox) == NIL)

The function imap_mailbox_name set mailbox name based on enum vm_box:
       if (box == NEW_FOLDER || box == OLD_FOLDER)
               snprintf(spec, len, "%s%s", tmp, use_folder? vms->imapfolder: "INBOX");
       else if (box == GREETINGS_FOLDER)
               snprintf(spec, len, "%s%s", tmp, greetingfolder);

But GREETINGS_FOLDER value is 5 and imap_mailbox_name set mailbox as Greeting instead of Cust1

To fix it we have to set GREETINGS_FOLDER value other then folders numbers
enum vm_box {
       NEW_FOLDER = 0,
       OLD_FOLDER = 1,
       WORK_FOLDER = 2,
       FAMILY_FOLDER = 3,
       FRIENDS_FOLDER = 4,
Comments:By: Rusty Newton (rnewton) 2015-03-31 16:10:42.956-0500

Thanks for the contribution! If you'd like your contribution to be included faster, you should submit your patch for code review by the Asterisk Developer Community. To do so, please follow the Code Review [1] instructions on the wiki. Be sure to:
* Verify that your patch conforms to the Coding Guidelines [2]
* Review the Code Review Checklist [3] for common items reviewers will look for
* If necessary, provide tests for the Asterisk Test Suite that verify the correctness of your patch [4]

When ready, submit your patch and any tests to Review Board [5] for code review.


[1] https://wiki.asterisk.org/wiki/display/AST/Code+Review
[2] https://wiki.asterisk.org/wiki/display/AST/Coding+Guidelines
[3] https://wiki.asterisk.org/wiki/display/AST/Code+Review+Checklist
[4] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Test+Suite+Documentation
[5] https://wiki.asterisk.org/wiki/display/AST/Review+Board+Usage

By: Rusty Newton (rnewton) 2015-03-31 16:12:19.401-0500

I posted our full canned response just for reference and if you want to do things yourself (which helps the Asterisk community out). If you want to simply attach your patch then we can walk it through.

It is always faster if you can push it through where you are able.

By: Rusty Newton (rnewton) 2015-03-31 16:17:22.791-0500

I'm going to link this to ASTERISK-24266 although they may be unrelated. They at least both relate to saving a message to a different folder in the context of IMAP. Perhaps a developer looking at this issue may look at and resolve the other.