diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-03 20:21:13 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-03 20:21:13 +0100 |
commit | 5d2261eb81e9e28bbaa1f52c668be164bb7a597d (patch) | |
tree | 8144a0b47cff3fa3bc4a7dfd090d55162191174d /perllib/FixMyStreet/App/Controller/Report | |
parent | 5e3cc91d5c7cb3c48418cf26064de2ba214e6567 (diff) |
Sign up new report to email alert if logged in as well as when confirmed by email. Allow disabling rather than deleting of alerts. Revert quoting as it breaks timestamps and literal SQL.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 671454272..9e0193d3f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -931,8 +931,10 @@ sub redirect_or_confirm_creation : Private { my ( $self, $c ) = @_; my $report = $c->stash->{report}; - # If confirmed send the user straigh there. + # If confirmed send the user straight there. if ( $report->confirmed ) { + # Subscribe problem reporter to email updates + $c->forward( 'create_reporter_alert' ); my $report_uri = $c->uri_for( '/report', $report->id ); $c->res->redirect($report_uri); $c->detach; @@ -950,6 +952,20 @@ sub redirect_or_confirm_creation : Private { $c->stash->{email_type} = 'problem'; } +sub create_reporter_alert : Private { + my ( $self, $c ) = @_; + + my $problem = $c->stash->{report}; + my $alert = $c->model('DB::Alert')->find_or_create( { + user => $problem->user, + alert_type => 'new_updates', + parameter => $problem->id, + cobrand => $problem->cobrand, + cobrand_data => $problem->cobrand_data, + lang => $problem->lang, + } )->confirm; +} + =head2 redirect_to_around Redirect the user to '/around' passing along all the relevant parameters. |