aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm18
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm21
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm4
3 files changed, 38 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
index 2d206d84e..468df2654 100644
--- a/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/AlertType.pm
@@ -94,7 +94,23 @@ sub email_alerts ($) {
}
# this is currently only for new_updates
if ($row->{item_text}) {
- $data{problem_url} = $url . "/report/" . $row->{id};
+ if ( $row->{alert_user_id} == $row->{user_id} ) {
+ # This is an alert to the same user who made the report - make this a login link
+ my $user = FixMyStreet::App->model('DB::User')->find( {
+ id => $row->{alert_user_id}
+ } );
+ $data{alert_email} = $user->email;
+ my $token_obj = FixMyStreet::App->model('DB::Token')->create( {
+ scope => 'email_sign_in',
+ data => {
+ email => $user->email,
+ r => 'report/' . $row->{id},
+ }
+ } );
+ $data{problem_url} = $url . "/M/" . $token_obj->token;
+ } else {
+ $data{problem_url} = $url . "/report/" . $row->{id};
+ }
$data{data} .= $row->{item_name} . ' : ' if $row->{item_name} && !$row->{item_anonymous};
$data{data} .= $row->{item_text} . "\n\n------\n\n";
# this is ward and council problems
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index 2f426e8ca..bb826a5ca 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -310,8 +310,8 @@ sub send_reports {
foreach my $council (@councils) {
my $name = $areas_info->{$council}->{name};
- my $sender = $cobrand->get_council_sender( $council, $areas_info->{$council} );
- $sender = "FixMyStreet::SendReport::$sender";
+ my $sender_info = $cobrand->get_council_sender( $council, $areas_info->{$council}, $row->category );
+ my $sender = "FixMyStreet::SendReport::" . $sender_info->{method};
if ( ! exists $senders->{ $sender } ) {
warn "No such sender [ $sender ] for council $name ( $council )";
@@ -324,7 +324,7 @@ sub send_reports {
$reporters{ $sender }->skipped;
} else {
push @dear, $name;
- $reporters{ $sender }->add_council( $council, $areas_info->{$council} );
+ $reporters{ $sender }->add_council( $council, $areas_info->{$council}, $sender_info->{config} );
}
}
@@ -422,6 +422,21 @@ sub send_reports {
}
printf " %-24s %4d\n", "Total:", $c;
}
+ my $sending_errors = '';
+ my $unsent = FixMyStreet::App->model("DB::Problem")->search( {
+ state => [ 'confirmed', 'fixed' ],
+ whensent => undef,
+ council => { '!=', undef },
+ send_fail_count => { '>', 0 }
+ } );
+ while (my $row = $unsent->next) {
+ $sending_errors .= "* http://www.fixmystreet.com/report/" . $row->id . ", failed "
+ . $row->send_fail_count . " times, last at " . $row->send_fail_timestamp
+ . ", reason " . $row->send_fail_reason . "\n";
+ }
+ if ($sending_errors) {
+ print "The following reports had problems sending:\n$sending_errors";
+ }
}
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
index bbf0c9a9e..d6b3eb5cb 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
@@ -62,7 +62,9 @@ sub send_questionnaires_period {
($template = $period) =~ s/ //;
$template = Utils::read_file( FixMyStreet->path_to( "templates/email/emptyhomes/" . $row->lang . "/questionnaire-$template.txt" )->stringify );
} else {
- $template = FixMyStreet->path_to( "templates", "email", $cobrand->moniker, "questionnaire.txt" )->stringify;
+ $template = FixMyStreet->path_to( "templates", "email", $cobrand->moniker, $row->lang, "questionnaire.txt" )->stringify;
+ $template = FixMyStreet->path_to( "templates", "email", $cobrand->moniker, "questionnaire.txt" )->stringify
+ unless -e $template;
$template = FixMyStreet->path_to( "templates", "email", "default", "questionnaire.txt" )->stringify
unless -e $template;
$template = Utils::read_file( $template );