aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-02 21:57:57 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-02 21:57:57 +0100
commit9ac1bac73d0b12f313d6863832b4b5547fded756 (patch)
tree0bdfc2ee72c86aa96df450130584ba69f3a90d8b /perllib/FixMyStreet/App.pm
parent2f98dc698dac2e5a4b8f2027d5c0336d444acd73 (diff)
Move most of questionnaire cron to ResultSet so it can be called and tested from test.
Diffstat (limited to 'perllib/FixMyStreet/App.pm')
-rw-r--r--perllib/FixMyStreet/App.pm23
1 files changed, 23 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 752263d10..10e0dbb28 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -8,6 +8,8 @@ use FixMyStreet::Cobrand;
use Memcached;
use Problems;
use mySociety::Email;
+use mySociety::EmailUtil;
+use mySociety::Random qw(random_bytes);
use FixMyStreet::Map;
use FixMyStreet::FakeQ;
@@ -308,6 +310,27 @@ sub send_email {
return $email;
}
+sub send_email_cron {
+ my ( $c, $params, $env_from, $env_to, $nomail ) = @_;
+
+ $params->{'Message-ID'} = sprintf('<fms-cron-%s-%s@mysociety.org>', time(),
+ unpack('h*', random_bytes(5, 1))
+ );
+
+ my $email = mySociety::Locale::in_gb_locale { mySociety::Email::construct_email($params) };
+
+ if ( FixMyStreet->test_mode ) {
+ my $sender = Email::Send->new({ mailer => 'Test' });
+ $sender->send( $email );
+ return 0;
+ } elsif (!$nomail) {
+ return mySociety::EmailUtil::send_email( $email, $env_from, @$env_to );
+ } else {
+ print $email;
+ return 1; # Failure
+ }
+}
+
=head2 uri_with
$uri = $c->uri_with( ... );