aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm18
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm13
2 files changed, 25 insertions, 6 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.
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index eadf2beea..a1120470b 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -315,12 +315,15 @@ sub signup_for_alerts : Private {
my ( $self, $c ) = @_;
if ( $c->stash->{add_alert} ) {
+ my $update = $c->stash->{update};
my $alert = $c->model('DB::Alert')->find_or_create(
- user => $c->stash->{update}->user,
- alert_type => 'new_updates',
- parameter => $c->stash->{update}->problem_id,
- confirmed => 1,
- );
+ user => $update->user,
+ alert_type => 'new_updates',
+ parameter => $update->problem_id,
+ cobrand => $update->cobrand,
+ cobrand_data => $update->cobrand_data,
+ lang => $update->lang,
+ )->confirm();
$alert->update;
}