aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm22
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) ) ) {