[Home]

Summary:ASTERISK-00619: Voicemail with postgres backend called with no context puts msgs in wrong place
Reporter:dhollis (dhollis)Labels:
Date Opened:2003-12-04 14:13:36.000-0600Date Closed:2008-01-15 14:39:50.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_voicemail_pgsql_singlequery.diff.txt
( 1) voicemail-query.patch
Description:Using postgres as the backend for voicemail, if you call Voicemail() without a context, messages are not left in the proper location.  Instead of being in voicemail/default/100/INBOX, they wind up in voicemail/100/INBOX.  This makes other interfaces not work as expected such as web voice mail, etc.

****** ADDITIONAL INFORMATION ******

The attached patch changes the query for cases where the context was not specified.  It retrieves the context for the user and sets it for the returned structure so that messages are put in the correct location.
Comments:By: Brian West (bkw918) 2003-12-04 16:37:21.000-0600

The context doesn't come from SQL that comes from the VoiceMail(blah@context)

Its not retreived from SQL...

               if (context) {
                       strcpy(retval->context, context);
               }

The issue is that we assume that no context = default.  I found this problem when writing unixodbc-vm-routines.h and the unixodbc voicemail routines don't suffer from this.

The second query should be: SELECT password,fullname,email,pager,options FROM voicemail WHERE context='default' AND mailbox='%s'

And then we do this:

if(context)
{
strcpy(retval->context, context);
}
else
{
strcpy(retval->context, "default");
}

Basically if we have a context we copy it... else we set it to default.

bkw

By: Brian West (bkw918) 2003-12-04 16:42:16.000-0600

I have attached a more proper fix.  Please confirm.

By: Brian West (bkw918) 2003-12-04 16:43:25.000-0600

Now that I think about it.. we only need one query if we do it like this! :P OH well I can fix that in the unixodbc stuff where we only have one query... I will leave it up to the person that did the pgsql support to fix this one.

By: Brian West (bkw918) 2003-12-04 16:46:33.000-0600

Ok tell me which one seems more proper?

By: Brian West (bkw918) 2003-12-04 17:13:07.000-0600

Fixed in CVS

By: dhollis (dhollis) 2004-01-07 13:27:35.000-0600

The patch applied does not fix the problem.  If the fprintf for the query is uncommented, the query (if called with no context) is constructed as '... WHERE context='' AND ....' which does not find any users.  A corrected patch is attached which also removes the 'if (*retval->context)' check since it is not required.  Based on the 'if (context)' check above the query sprintf, retval->context has what we want for the query so that is used.

By: Brian West (bkw918) 2004-01-07 13:31:04.000-0600

Yes that makes sense.. NO need to have that since we are going to have a context no matter what.  I will try to get this into cvs ASAP.

Thanks,
bkw

By: Brian West (bkw918) 2004-01-07 13:32:00.000-0600

accually  app_voicemail_pgsql_singlequery.diff.txt does exactly what you posted.  Dont know why that wasn't used... it was the patch that should have been put in CVS.  hrm.. anyway it will get fixed.

By: Malcolm Davenport (mdavenport) 2004-01-08 14:38:17.000-0600

Fixed in CVS.

By: Digium Subversion (svnbot) 2008-01-15 14:38:45.000-0600

Repository: asterisk
Revision: 1827

U   trunk/apps/app_voicemail.c
U   trunk/channels/chan_iax2.c

------------------------------------------------------------------------
r1827 | markster | 2008-01-15 14:38:44 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix PGSQL voicemail issues (bug ASTERISK-619) and fix reload races in iax2

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1827

By: Digium Subversion (svnbot) 2008-01-15 14:39:50.000-0600

Repository: asterisk
Revision: 1905

U   trunk/apps/app_voicemail.c

------------------------------------------------------------------------
r1905 | malcolmd | 2008-01-15 14:39:50 -0600 (Tue, 15 Jan 2008) | 3 lines

Fix Bug ASTERISK-619: Voicemail with PostgreSQL backend called with no context puts msgs in
wrong place

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1905