diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2012-06-21 17:29:58 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2012-06-21 17:29:58 +0100 |
commit | 45b3040884d7089e7d8c6f4acccd657b91c92a04 (patch) | |
tree | e5bb8f40c5a511b87e7cb7936ecc2f9b4b49ef73 /perllib/FixMyStreet/App/Controller/Report/Update.pm | |
parent | b3b1beeefb113da5c196a5f0ed62756f4777b162 (diff) |
Only create alert if actual parameters differ, not just cobrand/lang.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 779c74f03..3a2b40c2c 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -395,14 +395,20 @@ sub signup_for_alerts : Private { if ( $c->stash->{add_alert} ) { my $update = $c->stash->{update}; - my $alert = $c->model('DB::Alert')->find_or_create( - user => $update->user, - alert_type => 'new_updates', - parameter => $update->problem_id, - cobrand => $update->cobrand, - cobrand_data => $update->cobrand_data, - lang => $update->lang, - ); + my $options = { + user => $update->user, + alert_type => 'new_updates', + parameter => $update->problem_id, + }; + 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 ( $c->user && ( my $alert = $c->user->alert_for_problem($c->stash->{update}->problem_id) ) ) { |