[freeside-commits] branch master updated. 2c2da653a3d39945d8d2c244d102ccbee862053b

Ivan ivan at 420.am
Sat Oct 20 03:32:01 PDT 2012


The branch, master has been updated
       via  2c2da653a3d39945d8d2c244d102ccbee862053b (commit)
       via  cb51da1d9c3e75e1319705a5a2ed2d881c986ec4 (commit)
       via  f5c484dc3879f7e2e5eecca5614cf7236594ba1a (commit)
       via  0f3edcfc6b841251c08742a607d4fbaa1769baea (commit)
      from  744b17e5c9a5de68ad8a24b7a35449b535f02731 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2c2da653a3d39945d8d2c244d102ccbee862053b
Merge: cb51da1 744b17e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Oct 20 03:31:55 2012 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit cb51da1d9c3e75e1319705a5a2ed2d881c986ec4
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Oct 20 03:31:35 2012 -0700

    FS/FS/part_export/freeswitch_multifile.pm

diff --git a/FS/FS/part_export/freeswitch_multifile.pm b/FS/FS/part_export/freeswitch_multifile.pm
new file mode 100644
index 0000000..105ff02
--- /dev/null
+++ b/FS/FS/part_export/freeswitch_multifile.pm
@@ -0,0 +1,180 @@
+package FS::part_export::freeswitch_multifile;
+use base qw( FS::part_export );
+
+use vars qw( %info ); # $DEBUG );
+#use Data::Dumper;
+use Tie::IxHash;
+use Text::Template;
+#use FS::Record qw( qsearch qsearchs );
+#use FS::Schema qw( dbdef );
+
+#$DEBUG = 1;
+
+tie my %options, 'Tie::IxHash',
+  'user'  => { label => 'SSH username', default=>'root', },
+  'directory' => { label   => 'Directory to store FreeSWITCH account XML files',
+                   default => '/usr/local/freeswitch/conf/directory/',
+                 },
+  'domain'    => { label => 'Optional fixed SIP domain to use, overrides svc_phone domain', },
+  'reload'    => { label   => 'Reload command',
+                   default => '/usr/local/freeswitch/bin/fs_cli -x reloadxml',
+                 },
+  'user_template' => { label   => 'User XML configuration template',
+                       type    => 'textarea',
+                       default => <<'END',
+<domain name="<% $domain %>">
+  <user id="<% $phonenum %>">
+    <params>
+      <param name="password" value="<% $sip_password %>"/>
+    </params>
+  </user>
+</domain>
+END
+                     },
+;
+
+%info = (
+  'svc'     => 'svc_phone',
+  'desc'    => 'Provision phone services to FreeSWITCH XML configuration files (one file per user)',
+  'options' => \%options,
+  'notes'   => <<'END',
+Export XML account configuration files to FreeSWITCH, one per phone services.
+<br><br>
+You will need to
+<a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.9:Documentation:Administration:SSH_Keys">setup SSH for unattended operation</a>.
+END
+);
+
+sub rebless { shift; }
+
+sub _export_insert {
+  my( $self, $svc_phone ) = ( shift, shift );
+
+  eval "use Net::SCP;";
+  die $@ if $@;
+
+  #create and copy over file
+
+  my $tempdir = '%%%FREESIDE_CONF%%%/cache.'. $FS::UID::datasrc;
+
+  my $svcnum = $svc_phone->svcnum;
+
+  my $fh = new File::Temp(
+    TEMPLATE => "$tempdir/freeswitch.$svcnum.XXXXXXXX",
+    DIR      => $tempdir,
+    #UNLINK   => 0,
+  );
+
+  print $fh $self->freeswitch_template_fillin( $svc_phone, 'user' )
+    or die "print to freeswitch template failed: $!";
+  close $fh;
+
+  my $scp = new Net::SCP;
+  my $user = $self->option('user')||'root';
+  my $host = $self->machine;
+  my $dir = $self->option('directory');
+
+  $scp->scp( $fh->filename, "$user\@$host:$dir/$svcnum.xml" )
+    or return $scp->{errstr};
+
+  #signal freeswitch to reload config
+  $self->freeswitch_ssh( command => $self->option('reload') );
+
+  '';
+
+}
+
+sub _export_replace {
+  my( $self, $new, $old ) = ( shift, shift, shift );
+
+  $self->_export_insert($new, @_);
+}
+
+sub _export_delete {
+  my( $self, $svc_phone ) = ( shift, shift );
+
+  my $dir  = $self->option('directory');
+  my $svcnum = $svc_phone->svcnum;
+
+  #delete file
+  $self->freeswitch_ssh( command => "rm $dir/$svcnum.xml" );
+
+  #signal freeswitch to reload config
+  $self->freeswitch_ssh( command => $self->option('reload') );
+
+  '';
+}
+
+sub freeswitch_template_fillin {
+  my( $self, $svc_phone, $template ) = (shift, shift, shift);
+
+  $template ||= 'user'; #?
+
+  #cache a %tt hash?
+  my $tt = new Text::Template (
+    TYPE       => 'STRING',
+    SOURCE     => $self->option($template.'_template'),
+    DELIMITERS => [ '<%', '%>' ],
+  );
+
+  my $domain =  $self->option('domain')
+             || $svc_phone->domain
+             || '$${sip_profile}';
+
+  #false lazinessish w/phone_shellcommands::_export_command
+  my %hash = (
+    'domain' => $domain,
+    map { $_ => $svc_phone->getfield($_) } $svc_phone->fields
+  );
+
+  #might as well do em all, they're all going in an XML file as attribs
+  foreach ( keys %hash ) {
+    $hash{$_} =~ s/'/'/g;
+    $hash{$_} =~ s/"/"/g;
+  }
+
+  $tt->fill_in(
+    HASH => \%hash,
+  );
+}
+
+##a good idea to queue anything that could fail or take any time
+#sub shellcommands_queue {
+#  my( $self, $svcnum ) = (shift, shift);
+#  my $queue = new FS::queue {
+#    'svcnum' => $svcnum,
+#    'job'    => "FS::part_export::freeswitch::ssh_cmd",
+#  };
+#  $queue->insert( @_ );
+#}
+
+sub freeswitch_ssh { #method
+  my $self = shift;
+  ssh_cmd( user    => $self->option('user')||'root',
+           host    => $self->machine,
+           @_,
+         );
+}
+
+sub ssh_cmd { #subroutine, not method
+  use Net::OpenSSH;
+  my $opt = { @_ };
+  open my $def_in, '<', '/dev/null' or die "unable to open /dev/null";
+  my $ssh = Net::OpenSSH->new( $opt->{'user'}.'@'.$opt->{'host'},
+                               default_stdin_fh => $def_in,
+                             );
+  die "Couldn't establish SSH connection: ". $ssh->error if $ssh->error;
+  my ($output, $errput) = $ssh->capture2( #{stdin_discard => 1},
+                                          $opt->{'command'}
+                                        );
+  die "Error running SSH command: ". $ssh->error if $ssh->error;
+
+  #who the fuck knows what freeswitch reload outputs, probably a fucking
+  # ascii advertisement for cluecon
+  #die $errput if $errput;
+  #die $output if $output;
+
+  '';
+}
+
+1;

commit f5c484dc3879f7e2e5eecca5614cf7236594ba1a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Oct 20 03:31:00 2012 -0700

    pass currency flag with voids and refunds too, for Canadian Moneris, RT#18684

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index f9f90a7..ad2bdf9 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -1444,6 +1444,10 @@ sub realtime_refund_bop {
     if length($auth); #echeck/ACH transactions have an order # but no auth
                       #(at least with authorize.net)
 
+  my $currency =    $conf->exists('business-onlinepayment-currency')
+                 && $conf->config('business-onlinepayment-currency');
+  $content{currency} = $currency if $currency;
+
   my $disable_void_after;
   if ($conf->exists('disable_void_after')
       && $conf->config('disable_void_after') =~ /^(\d+)$/) {

commit 0f3edcfc6b841251c08742a607d4fbaa1769baea
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Oct 19 14:08:27 2012 -0700

    option to omit $0 CDRs, RT#19917

diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 8c3d80d..28d5038 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -229,6 +229,10 @@ tie my %unrateable_opts, 'Tie::IxHash',
                        },
     #eofalse
 
+    'usage_nozero' => { 'name' => 'Omit details for included / no-charge calls.',
+                        'type' => 'checkbox',
+                      },
+
     'bill_every_call' => { 'name' => 'Generate an invoice immediately for every call (as well any setup fee, upon first payment).  Useful for prepaid.',
                            'type' => 'checkbox',
                          },
@@ -358,6 +362,8 @@ sub calc_usage {
                                  : 'default'
                              );
 
+  my $usage_nozero      = $self->option->('usage_nozero', 1);
+
   my $formatter = FS::detail_format->new($output_format, buffer => $details);
 
   my $use_duration = $self->option('use_duration');
@@ -441,7 +447,7 @@ sub calc_usage {
         $error = $cdr->set_status('done');
       }
       die $error if $error;
-      $formatter->append($cdr);
+      $formatter->append($cdr) unless $usage_nozero && $cdr->rated_price == 0;
 
       $cdr_search->adjust(1) if $cdr->freesidestatus eq 'rated';
     } #$cdr

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

Summary of changes:
 FS/FS/cust_main/Billing_Realtime.pm                |    4 +
 .../{freeswitch.pm => freeswitch_multifile.pm}     |   90 +++++++++-----------
 FS/FS/part_pkg/voip_cdr.pm                         |    8 ++-
 3 files changed, 50 insertions(+), 52 deletions(-)
 copy FS/FS/part_export/{freeswitch.pm => freeswitch_multifile.pm} (74%)




More information about the freeside-commits mailing list