Browse files

Shell out to send email so we do not get recv blocks

  • Loading branch information...
1 parent b6d7ba2 commit dc59e6f4a77f1ac29244782485932b0ce9758f12 Luke Closs committed Jun 11, 2012
Showing with 23 additions and 20 deletions.
  1. +5 −11 bin/job-runner
  2. +18 −9 bin/send-receipt
View
16 bin/job-runner
@@ -39,11 +39,6 @@ my $daemon = Biopay::Daemon->new(
# receipt code
system($^X, "$FindBin::Bin/send-receipt", $job->_id)
and die "Could not send receipt for job " . $job->_id;
- if ($member->in_protest) {
- print " (Protest from @{[$member->id]}) ";
- system($^X, "$FindBin::Bin/send-protest", $member->id)
- and die "Could not send protest for member " . $member->id;
- }
},
'register-member' => sub {
my ($job, $member) = @_;
@@ -309,13 +304,12 @@ sub process_transactions {
$error = "Order '$order_num' processed, txns marked as paid, but "
. "receipt is not sent.";
- Biopay::EmailReceipt->new(
- member_id => $member->id,
- member => $member,
- txns => $txns,
+ Biopay::Command->Create(
+ command => 'send-receipt',
+ member_id => $mid,
+ txn_ids => [ map { $_->id } @$txns ],
($need_to_renew_membership ? (dues => $membership_price) : ())
- )->send;
- print " (Receipt to: " . $member->email . ") " if $member->email;
+ );
}
catch {
my $err = $_;
View
27 bin/send-receipt
@@ -21,26 +21,35 @@ GetOptions( \%opts,
) or usage();
my $job_id = shift;
+my $member;
if (my $mid = $opts{'resend-last'}) {
- my $receipt = Biopay::Member->By_id($mid)->last_receipt;
+ $member = Biopay::Member->By_id($mid);
+ my $receipt = $member->last_receipt;
die "Couldn't find any receipts for member #$mid" unless $receipt;
Biopay::EmailReceipt->new(
member_id => $mid,
txn_ids => $receipt->txn_ids,
dues => $receipt->dues,
)->send;
- exit;
}
+elsif ($job_id) {
+ my $job = Biopay::Command->By_id($job_id) || die "Couldn't load command $job_id";
+ die "Command is of the wrong type: " . $job->{command}
+ unless $job->{command} eq 'send-receipt';
-usage() unless $job_id;
-
-
-my $job = Biopay::Command->By_id($job_id) || die "Couldn't load command $job_id";
+ Biopay::EmailReceipt->new($job->args)->send;
+ $member = Biopay::Member->By_id($job->args->{member_id});
+}
+else {
+ usage();
+}
-die "Command is of the wrong type: " . $job->{command}
- unless $job->{command} eq 'send-receipt';
+if ($member and $member->in_protest) {
+ print " (Protest from @{[$member->id]}) ";
+ system($^X, "$FindBin::Bin/send-protest", $member->id)
+ and die "Could not send protest for member " . $member->id;
+}
-Biopay::EmailReceipt->new($job->args)->send;
exit;

0 comments on commit dc59e6f

Please sign in to comment.