aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-12 18:00:44 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-12 18:00:50 +0100
commit9606353b3d3fb3be9e6b1d25dda154a7fdc33b10 (patch)
tree7f1dc9295198d183af63e87852e8cb60b6614512 /perllib/FixMyStreet
parentc4bc439991b5edbe4b177c07d7e9f99bbffb34e1 (diff)
If update alert email is to problem reporter, make it a login link.
This is so they can more easily update, especially if the update they've just received has mistakingly 'fixed' the report. This fixes #7.
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/AlertType.pm18
1 files changed, 17 insertions, 1 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