diff options
author | pezholio <pezholio@gmail.com> | 2017-05-05 15:20:31 +0100 |
---|---|---|
committer | pezholio <pezholio@gmail.com> | 2017-05-05 15:24:12 +0100 |
commit | 77ff26ef363a54f0c550649d2a02bad0f449b926 (patch) | |
tree | 4092f1d31577fdef3cc303bc6836042129466b91 /perllib/FixMyStreet/App/Controller/Report/Update.pm | |
parent | 1c07eca3d6e8cea5d70c043de02d30bd7cdc5630 (diff) |
Move alert signup logic out of controller
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 4c2d92d5e..6e94547f3 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -548,24 +548,17 @@ sub signup_for_alerts : Private { my ( $self, $c ) = @_; my $update = $c->stash->{update}; + my $user = $update->user; + my $problem_id = $update->problem_id; + if ( $c->stash->{add_alert} ) { my $options = { - user => $update->user, - alert_type => 'new_updates', - parameter => $update->problem_id, + cobrand => $update->cobrand, + cobrand_data => $update->cobrand_data, + lang => $update->lang, }; - my $alert = $c->model('DB::Alert')->find($options); - unless ($alert) { - $alert = $c->model('DB::Alert')->create({ - %$options, - cobrand => $update->cobrand, - cobrand_data => $update->cobrand_data, - lang => $update->lang, - }); - } - $alert->confirm(); - - } elsif ( my $alert = $update->user->alert_for_problem($update->problem_id) ) { + $user->create_alert($problem_id, $options); + } elsif ( my $alert = $user->alert_for_problem($problem_id) ) { $alert->disable(); } |