aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-12 09:04:31 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-12 09:04:31 +0100
commit2d1e3699cdd1e4d7cefa348b338c92de2d90facb (patch)
tree7b91a2be1bb5817b7a3190d527d47d001b2990a4
parentd4210bdddb954f5f1b895133d1336fed149174f5 (diff)
use models to sign up problem reporter to new update alerts
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 9cbbc42b4..8e45581a8 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -57,10 +57,15 @@ sub confirm_problem : Path('/P') {
) if $problem->state eq 'unconfirmed';
# Subscribe problem reporter to email updates
- my $alert_id =
- FixMyStreet::Alert::create( $problem->user->email, 'new_updates',
- $problem->cobrand, $problem->cobrand_data, $problem_id );
- FixMyStreet::Alert::confirm($alert_id);
+ my $alert = $c->model('DB::Alert')->find_or_create(
+ {
+ user => $problem->user,
+ alert_type => 'new_updates',
+ cobrand => $problem->cobrand,
+ cobrand_data => $problem->cobrand_data,
+ parameter => $problem->id
+ }
+ )->confirm;
# log the problem creation user in to the site
$c->authenticate( { email => $problem->user->email }, 'no_password' );