aboutsummaryrefslogtreecommitdiffstats
path: root/bin/send-questionnaires
diff options
context:
space:
mode:
authormatthew <matthew>2007-05-08 18:16:34 +0000
committermatthew <matthew>2007-05-08 18:16:34 +0000
commit251d80fb7b2c14d23ea005d7277f4fefc34282a6 (patch)
treef463efac5e1ffd6fb441971d680d311779024324 /bin/send-questionnaires
parent8a17fba62dad81bbfe7a7f763d1c29bee66b8318 (diff)
Add questionnaire to cron.
Diffstat (limited to 'bin/send-questionnaires')
-rwxr-xr-xbin/send-questionnaires10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/send-questionnaires b/bin/send-questionnaires
index a6a865dca..a13ab4faa 100755
--- a/bin/send-questionnaires
+++ b/bin/send-questionnaires
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: send-questionnaires,v 1.3 2007-05-04 15:57:43 matthew Exp $
+# $Id: send-questionnaires,v 1.4 2007-05-08 18:16:34 matthew Exp $
use strict;
require 5.8.0;
@@ -73,7 +73,8 @@ foreach my $row (@$unsent) {
values (?, ?, ms_current_timestamp())', {}, $id, $row->{id});
dbh()->do("update problem set send_questionnaire = 'f' where id=?", {}, $row->{id});
- $h{url} = mySociety::Config::get('BASE_URL') . '/Q/' . mySociety::AuthToken::store('questionnaire', $id);
+ my $token = mySociety::AuthToken::store('questionnaire', $id);
+ $h{url} = mySociety::Config::get('BASE_URL') . '/Q/' . $token;
my $email = mySociety::Email::construct_email({
_template_ => $template,
@@ -82,16 +83,19 @@ foreach my $row (@$unsent) {
From => [ mySociety::Config::get('CONTACT_EMAIL'), 'Neighbourhood Fix-It' ],
});
+ print "Sending questionnaire $id, problem $row->{id}, token $token to $row->{email}\n" if $verbose;
+
my $result;
if ($nomail) {
$result = -1;
- print $email;
} else {
$result = mySociety::EmailUtil::send_email($email, mySociety::Config::get('CONTACT_EMAIL'), $row->{email});
}
if ($result == mySociety::EmailUtil::EMAIL_SUCCESS) {
+ print " ...success\n" if $verbose;
dbh()->commit();
} else {
+ print " ...failed\n" if $verbose;
dbh()->rollback();
}
}