diff --git a/logcall/models/crm_phonecall.py b/logcall/models/crm_phonecall.py index 66d896a..356155a 100644 --- a/logcall/models/crm_phonecall.py +++ b/logcall/models/crm_phonecall.py @@ -164,6 +164,7 @@ class PhoneCommon(models.AbstractModel): 'type': 'url', 'mimetype': 'audio/wav', 'url': base_url.format(caller_user=caller_user, + user_resource=users[0].resource, odoo_type=odoo_type, odoo_src=odoo_src, odoo_dst=odoo_dst, diff --git a/logcall/scripts/fusionpbx_get_recording.pl b/logcall/scripts/fusionpbx_get_recording.pl new file mode 100644 index 0000000..9256d02 --- /dev/null +++ b/logcall/scripts/fusionpbx_get_recording.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +# Set ucp_url to something like this: +# https://webserver/cgi-bin/fusionpbx_get_recording.pl?file={odoo_uuid}&start={odoo_start}&resource={user_resource} + +my(%args); +if($ENV{'REQUEST_METHOD'} eq "GET") { + $query=$ENV{'QUERY_STRING'}; + my(@line_args)=split(/&/,$query); + + for my $arg (@line_args){ + $arg=~ s/\+/ /g; # replace + with spaces..... + ($key,$val)=split(/=/,$arg); + $val =~ s/%(..)/pack("c",hex($1))/ge; + if($key eq "file" || $key eq "usename" || $key eq "content" ||$key eq "remove" ){ + $args{$key}=$val; + } + } + + +} +else{ + print "Content-type: text/html\n\n"; + print "No Arguments....."; + exit 1; +} + +my $time = $start; +my @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); +my ($sec, $min, $hour, $day,$month,$year) = (gmtime($time))[0,1,2,3,4,5]; + +print "Unix time ".$time." converts to ".$months[$month]." ".$day.", ".($year+1900); +print " ".$hour.":".$min.":".$sec."\n"; + +$resource =~ s/@/./ + +$filename="/usr/local/freeswitch/recordings/".$resource."/".$year."/".$months[$month]."/".$day."/".$args{"file"}; +my(@stat)=stat $filename; +binmode(STDOUT); +if(open (F,"<", "$filename")){ + print "Connection: close\n"; + if($args{"content"}){ + print "Content-Type: ".$args{"content"}."\n\\"; + } + else{ + print "Content-Type: application/octet-stream\n"; + } + + print "Content-Length: ".$stat[7]."\n"; + if($args{"usename"}){ + print "Content-Disposition: attachment; filename=\"".$args{"usename"}."\"\n\n"; + } + else { + print "Content-Disposition: attachment; filename=\"".$args{"file"}."\"\n\n"; + } + + while($len=sysread( F, $buf,512)){ + print $buf; + } + close F; + if($args{"remove"}==1){ + unlink $filename; + } +} +else { + print "Connection: close\n"; + print "Content-Type: text/html\n\n"; + print "

Error

\n"; + print "The file ".$args{"file"}." does not exists in the server
\n"; + print "Please contact to the administrator for more info.\n\n"; +} +