@ -8,6 +8,7 @@ use HTTP::Status qw(:constants);
use NGCP::Panel::Utils::ValidateJSON qw( ) ;
use NGCP::Panel::Utils::Subscriber ;
use NGCP::Panel::Utils::Sounds ;
require Catalyst::ActionRole::ACL ;
require NGCP::Panel::Role::HTTPMethods ;
require Catalyst::ActionRole::RequireSSL ;
@ -61,10 +62,17 @@ sub GET :Allow {
last unless $ self - > valid_id ( $ c , $ id ) ;
my $ item = $ self - > item_by_id ( $ c , $ id ) ;
last unless $ self - > resource_exists ( $ c , voicemailrecording = > $ item ) ;
my $ filename = NGCP::Panel::Utils::Subscriber:: get_voicemail_filename ( $ c , $ item ) ;
my $ format = $ c - > request - > params - > { format } // 'wav' ;
unless ( $ format && $ format =~ /^(wav|mp3|ogg)$/ ) {
$ self - > error ( $ c , HTTP_INTERNAL_SERVER_ERROR , "Unknown format '$format', supported: wav,mp3,ogg." ) ;
last ;
}
my $ sr = \ % NGCP:: Panel:: Utils:: Subscriber:: ;
my $ ss = \ % NGCP:: Panel:: Utils:: Sounds:: ;
my $ filename = $ sr - > { get_voicemail_filename } ( $ c , $ item , $ format ) ;
$ c - > response - > header ( 'Content-Disposition' = > 'attachment; filename="' . $ filename . '"' ) ;
$ c - > response - > content_type ( 'audio/x-wav' ) ;
$ c - > response - > body ( $ item - > recording ) ;
$ c - > response - > content_type ( $ sr - > { get_voicemail_content_type } ( $ c , $ format ) ) ;
$ c - > response - > body ( $ ss- > { transcode_data } ( $ item- > recording , 'WAV' , uc ( $ format ) ) ) ;
return ;
}
return ;