2016-01-02 18:33:35 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use autodie qw(open close);
|
|
|
|
use DBI;
|
|
|
|
use Encode qw(encode decode);
|
|
|
|
|
2016-01-02 18:33:57 +00:00
|
|
|
use Supporters;
|
|
|
|
|
2016-01-02 18:33:35 +00:00
|
|
|
my $LEDGER_CMD = "/usr/local/bin/ledger";
|
|
|
|
|
|
|
|
if (@ARGV != 4 and @ARGV != 5) {
|
|
|
|
print STDERR "usage: $0 <SUPPORTERS_SQLITE_DB_FILE> <WHO> <HOW> <SUPPORTER_CHECKLIST_TEX_FILE> <VERBOSITY_LEVEL>\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my($SUPPORTERS_SQLITE_DB_FILE, $WHO, $HOW, $TEX_FILE, $VERBOSE) = @ARGV;
|
|
|
|
$VERBOSE = 0 if not defined $VERBOSE;
|
|
|
|
|
|
|
|
my $dbh = DBI->connect("dbi:SQLite:dbname=$SUPPORTERS_SQLITE_DB_FILE", "", "",
|
|
|
|
{ RaiseError => 1, sqlite_unicode => 1 })
|
|
|
|
or die $DBI::errstr;
|
|
|
|
|
|
|
|
my $sp = new Supporters($dbh, [ "none" ]);
|
|
|
|
|
|
|
|
my %idsSent;
|
|
|
|
open(TEX_FILE, "<", $TEX_FILE);
|
|
|
|
|
|
|
|
while (my $line = <TEX_FILE>) {
|
|
|
|
if ($line =~ /Box.*\&\s*(\d+)\s*\&\s*(\S+)\s*\&\s*(\S+)\s*\&/) {
|
|
|
|
my($id, $ledgerEntityId, $size) = ($1, $2, $3);
|
|
|
|
die "id $id, and/or size $size not defined" unless defined $id and defined $size;
|
|
|
|
$idsSent{$id} = $size;
|
|
|
|
} else {
|
2016-01-02 18:47:09 +00:00
|
|
|
print STDERR "skipping line $line" if ($VERBOSE >= 2);
|
2016-01-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close TEX_FILE;
|
|
|
|
|
|
|
|
foreach my $id (sort keys %idsSent) {
|
|
|
|
my $request;
|
2016-12-08 23:08:53 +00:00
|
|
|
my @requestTypes = $sp->getRequestType();
|
|
|
|
foreach my $type (@requestTypes) {
|
|
|
|
next unless if ($type =~ /t-shirt/);
|
|
|
|
$request = $sp->getRequest({ donorId => $id, requestType => $type,
|
|
|
|
ignoreHeldRequests => 1, ignoreFulfilledRequests => 1 });
|
2016-01-02 18:33:35 +00:00
|
|
|
if (defined $request and defined $request->{requestType}) {
|
2016-01-02 18:35:05 +00:00
|
|
|
if ($request->{requestConfiguration} ne $idsSent{$id}) {
|
2016-01-02 18:33:35 +00:00
|
|
|
my $out = "WARNING: not fufilling $id request for $request->{requstConfiguration} because we sent wrong size of $idsSent{$id}!\n";
|
|
|
|
print $out;
|
|
|
|
print STDERR $out;
|
|
|
|
$request = undef;
|
|
|
|
}
|
|
|
|
}
|
2016-10-20 18:18:59 +00:00
|
|
|
last if defined $request;
|
2016-01-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
if (not defined $request) {
|
|
|
|
my $out = "WARNING: We seem to have sent $id an $idsSent{$id} t-shirt that $id didn't request! Ignoring that and contuining...\n";
|
|
|
|
print $out;
|
|
|
|
print STDERR $out;
|
|
|
|
next;
|
|
|
|
}
|
2016-01-02 18:36:35 +00:00
|
|
|
$sp->fulfillRequest({ donorId => $id, requestType => $request->{requestType},
|
|
|
|
who => $WHO, how => $HOW});
|
2016-01-02 18:33:35 +00:00
|
|
|
|
2017-01-02 19:54:25 +00:00
|
|
|
next unless $sp->emailOk($donorId);
|
2016-01-02 18:33:35 +00:00
|
|
|
my $emailTo = $sp->getPreferredEmailAddress($id);
|
|
|
|
if (not defined $emailTo) {
|
|
|
|
my(@addr) = $sp->getEmailAddresses($id);
|
|
|
|
$emailTo = $addr[0];
|
|
|
|
}
|
|
|
|
my $fromAddress = 'info@sfconservancy.org';
|
2016-03-01 01:58:37 +00:00
|
|
|
my $pingNoGet = "";
|
|
|
|
$pingNoGet = "\nPlease ping us if you do not receive your t-shirt within two weeks in the\nUSA, or three weeks outside of the USA.\n\n"
|
|
|
|
if ($HOW =~ /post/);
|
|
|
|
|
2016-01-02 18:47:29 +00:00
|
|
|
open(SENDMAIL, "|/usr/lib/sendmail -f \"$fromAddress\" -oi -oem -- $emailTo $fromAddress") or
|
2016-01-02 18:33:35 +00:00
|
|
|
die "unable to run sendmail: $!";
|
|
|
|
print SENDMAIL <<DATA;
|
|
|
|
To: $emailTo
|
|
|
|
From: "Software Freedom Conservancy" <$fromAddress>
|
2016-10-20 18:18:32 +00:00
|
|
|
Subject: $idsSent{$id} Conservancy T-Shirt was $HOW
|
2016-01-02 18:33:35 +00:00
|
|
|
|
2016-03-01 01:58:37 +00:00
|
|
|
According to our records, the t-shirt of size $idsSent{$id} that you
|
|
|
|
requested as a Conservancy Supporter was $HOW.
|
|
|
|
$pingNoGet
|
2016-01-02 18:33:35 +00:00
|
|
|
|
2016-10-20 18:18:32 +00:00
|
|
|
Thank you again so much for supporting Conservancy. When we placed our order
|
|
|
|
for these t-shirts, our shirt supplier (which is itself a 501c3 dedicated to
|
|
|
|
educating high school kids in New York) sent us the wrong color t-shirt
|
|
|
|
before appropriately filling the order in a deep gray. We decided to give you
|
|
|
|
a second shirt in this fun color as an extra thank you for being a Supporter.
|
|
|
|
|
|
|
|
The two shirts now feel like a symbol for where we are in our Supporter
|
|
|
|
program - if each of our Supporters just got a single friend to sign up, we'd
|
|
|
|
achieve sustainability for all of Conservancy's programs.
|
|
|
|
|
|
|
|
We'd really appreciate if you'd post pictures of the shirt on social media
|
|
|
|
and encourage others to sign up as a Conservancy supporter at
|
|
|
|
https://sfconservancy.org/supporter/ .
|
2016-01-02 18:33:35 +00:00
|
|
|
|
|
|
|
Sincerely,
|
|
|
|
--
|
2016-01-07 06:22:44 +00:00
|
|
|
Karen M. Sandler, Executive Director, Software Freedom Conservancy
|
|
|
|
and
|
|
|
|
Bradley M. Kuhn, Distinguished Technologist, Software Freedom Conservancy
|
2016-01-02 18:33:35 +00:00
|
|
|
DATA
|
|
|
|
close SENDMAIL;
|
|
|
|
die "Unable to send email to $id: $!" unless $? == 0;
|
2016-01-02 18:47:22 +00:00
|
|
|
|
|
|
|
print STDERR "Emailed $emailTo for $id sending of $request->{requestConfiguration} size t-shirt and marked it fulfilled in database\n" if ($VERBOSE);
|
2016-01-02 18:33:35 +00:00
|
|
|
}
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Local variables:
|
|
|
|
# compile-command: "perl -c send-t-shirts.plx"
|
|
|
|
# End:
|
|
|
|
|