Saturday, September 25, 2010

Bug Fixing......

Well After tempnut2 was put in to live there were about 5 conferences being used so far...

sigh............


This week was very interesting as I got a bug to fix in our email to fax system and also with the conference server.

The one with conference server was straight forward and I knew about that before hand , But didn't get a time to fix it once and for all. It just a poor DTMF handling logic though

First I worked on the bug with the email to fax system where we allow people to send attachments in many formats like txt,html,rtf,png,jpg,bmp,pdf,tiff,doc,docx,ppt,xls
withing an email and send it out as a fax to the destination. All these formats were converted to pdf at processing before sending it out to fax server.


Problem was with txt and rtf formats where they were not actually tested before with the system.

When I started to investigate the problem with .rtf attachments after spending two three hours on a php script which is doing the email decoding and dispatch the attachment to the fax server What I realize was that any raw data of an attachment is pass through a php base64_decode() function which was causing .rtf files being corrupted.

The real problem was that it assumed that any attachment of an email is subjected to MIME encoding when email send to a server where as .rtf/.txt does not.

So the actual problem was that the .rtf files are not subject to any encoding as it send as plain text format in an email attachment.

.rtf documents have an html style syntax where everything in .rtf enclose within a {}.

So It just a matter of by passing the bas64_decode() function only for .rtf files....

ooooopzzzzzzzzzz... also for .txt files as well.


So All I have done for patch this is the below simple logic in email decoding script.

if($attachment== "rtf"){
$attachment = stripslashes($attachment); # get rid of \\
# some other string substitutions for specific email clients like outlook
}
else if($attachment== "rtf"){
$attachment= $attachment
}
else{
$attachment = base64_decode($attachment);
}

And here we go........ I applied the patch to production yesterday and all went good :)


Hmmm ......................................
about the problem with the conference server was that I have used wait_for_digit AGI function to capture the dtmf inputs on conference authentication in AGI script.

I used the stream_file function to play relevant voice prompts, problem was that If user start to input stuff while announcement is in progress I miss the first digit that user press


It's like below,

$agi->stream_file("enter-confroom");
$room = get_hash_terminate_input($agi);


So to fix it, I used the below solution which worked on fly :)

$intkey = $agi->stream_file("enter-confroom","0123456789"); # any digit will interrupt the voiceprompt [0-9]
$key = get_interrupt_key($intkey);
$room = get_hash_terminate_input($agi,$key);

get_interrupt_key($intkey) function handles the interrupt key well, as even if the user press a key or he just wait till voice prompts over doesn't matter :)

Hmmmm thats all about bug fixing............................ :D

I'm gonna stop for today........................................

No comments:

Post a Comment