Summary:ASTERISK-14610: [patch] Checking IMAP folder for voicemail only gets messages in the same context and extension
Reporter:Noah Miller (noahisaac)Labels:
Date Opened:2009-08-06 12:46:14Date Closed:2010-08-18 12:42:05
Versions:Frequency of
Environment:Attachments:( 0) imap-voicemail-nocontexts.patch
Description:I believe the summary is the intended behavior, but I'm submitting this as a bug because this behavior is (perhaps) inconsistent with the behavior of file-based voicemail, and it artificially limits the possibilities of accessing/relaying messages with a standard IMAP email client.

In file-based voicemail, if you put a msgXXXX.wav/msgXXXX.txt pair into any voicemail folder, it will be accessible from the intended user's VoicemailMain().  It does not matter what the msgXXXX.txt file says for the extension or context.

In IMAP voicemail, though, messagecount() and open_mailbox() only get messages in the target IMAP folder where the "X-Asterisk-VM-Context" and "A-Asterisk-VM-Extension" match the current user's context and extension.  If you drag and drop a message from one user to another in an IMAP email client, the intended recipient will not be able to access the message from his/her phone because the extension and/or context would be different.  The c-client calls look like this:

hdr = mail_newsearchheader("X-Asterisk-VM-Extension", (!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : vmu->mailbox));
hdr->next = mail_newsearchheader("X-Asterisk-VM-Context", vmu->context);

I think it should be changed to just look for any asterisk voicemail messages in the target IMAP folder.  This does the trick:

hdr = mail_newsearchheader("X-Asterisk-VM-Message-Type", "Message");

I know that file-based voicemails are in completely separate directories for different contexts, so the context-specific check for IMAP voicemail is maybe not entirely inconsistent.  Perhaps, if this behavior is really desired, we could use the "searchcontexts" option from voicemail.conf to specify whether to get messages from all contexts, or just the current one.


I'll post a patch.
Comments:By: Leif Madsen (lmadsen) 2009-08-06 14:12:07

I wouldn't mind seeing a patch posted for this. It seems natural that moving voicemails around boxes with IMAP should have the intended effect of having access to the voicemail.

Although there could be a reason this isn't supposed to work. I just can't think of a reason off the bat :)

By: Leif Madsen (lmadsen) 2009-09-18 07:29:19

Setting this to feedback.

Does the original reporter still have interest in submitting a patch?

By: Noah Miller (noahisaac) 2009-09-18 14:29:44

Yes, I'll post a patch.  Sorry, I had forgotten.

By: Noah Miller (noahisaac) 2009-09-18 14:41:15

Note: the patch is for Asterisk, and boy is it ever a complex monster (j/k).

By: Leif Madsen (lmadsen) 2009-09-22 09:25:24

Ideally this should probably be posted against trunk.

Could you round up some troops from the asterisk-dev and/or asterisk-users mailing list to test this out? If anyone else has this issue and the patch resolves the issue for them, that will go a long way to getting this committed. Thanks!

By: Tilghman Lesher (tilghman) 2010-07-21 16:11:32

I think what I'd prefer here would be to change the headers, if possible.  I don't know how difficult that would be, and the API documents on libc-client suck rather badly, but I'm looking into it.

By: Tilghman Lesher (tilghman) 2010-08-18 12:41:49

Actually, there's a good reason why this shouldn't work.  Some people set up their IMAP as a simple storage mechanism, with a single store for everything.  Changing how this works would cause those setups to fail.

If you want to move voicemails from one user to another, you should be forwarding the voicemail through the voicemail interface, or you should use a client that understands the differences between our custom flags and changes them as appropriate.