diff options
-rw-r--r-- | CHANGELOG.md | 21 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Moderate.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 15 | ||||
-rw-r--r-- | t/app/controller/moderate.t | 32 |
4 files changed, 59 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a5fa47edc..06bc040c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Don't cover whole map with pin loading indicator. - Add Expand map toggle to more mobile maps. - Add functionality to have per-body /reports page. + - Cobrands can disable sending of moderation emails. #1910 - Front end improvements: - SVG assets for core elements like button icons and map controls #1888 - Remove unneeded 2x PNG fallback images. @@ -31,16 +32,16 @@ - Stop page jumping too far down on inspect form. #1863 - Prevent multiple 'Expand map' links appearing. #1909 - Admin improvements: - - Character length limit can be placed on report detailed information #1848 - - Inspector panel shows nearest address if available #1850 - - Return a 200 rather than 404 for ref ID lookup. - - Public report page shows state changes made in admin interface #1846 - - Remove hidden from default staff state dropdown. #1878 - - Marking an item as a duplicate enforces providing duplicate id or - a public update #1873 - - Report field pre-filling for inspectors configurable #1854 - - Admins can now unban users #1881 - - Council dashboard has date range for report generation #1885 + - Character length limit can be placed on report detailed information #1848 + - Inspector panel shows nearest address if available #1850 + - Return a 200 rather than 404 for ref ID lookup. + - Public report page shows state changes made in admin interface #1846 + - Remove hidden from default staff state dropdown. #1878 + - Marking an item as a duplicate enforces providing duplicate id or + a public update #1873 + - Report field pre-filling for inspectors configurable #1854 + - Admins can now unban users #1881 + - Council dashboard has date range for report generation #1885 - UK: - Use SVG logo, inlined on front page. #1887 - Inline critical CSS on front page. diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index 4d3a97fa8..a8e0b7a3c 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -103,7 +103,7 @@ sub report_moderate_audit : Private { reason => (sprintf '%s (%s)', $reason, $types_csv), }); - if ($problem->user->email_verified) { + if ($problem->user->email_verified && $c->cobrand->send_moderation_notifications) { my $token = $c->model("DB::Token")->create({ scope => 'moderation', data => { id => $problem->id } diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 68d11f227..82455f262 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -1250,4 +1250,19 @@ sub social_auth_enabled { return $key_present && !$self->call_hook("social_auth_disabled"); } + +=head2 send_moderation_notifications + +Used to control whether an email is sent to the problem reporter when a report +is moderated. + +Note that this is called in the context of the cobrand used to perform the +moderation, so e.g. if a UK council cobrand disables the moderation +notifications and a report is moderated on fixmystreet.com, the email will +still be sent (because it wasn't disabled on the FixMyStreet cobrand). + +=cut + +sub send_moderation_notifications { 1 } + 1; diff --git a/t/app/controller/moderate.t b/t/app/controller/moderate.t index c31f4880f..4b2f0cfe3 100644 --- a/t/app/controller/moderate.t +++ b/t/app/controller/moderate.t @@ -1,3 +1,11 @@ +package FixMyStreet::Cobrand::Tester; + +use parent 'FixMyStreet::Cobrand::Default'; + +sub send_moderation_notifications { 0 } + +package main; + use FixMyStreet::TestMech; use FixMyStreet::App; use Data::Dumper; @@ -176,6 +184,30 @@ subtest 'Problem moderation' => sub { # reset $report->update({ state => 'confirmed' }); }; + + subtest 'Hide report without sending email' => sub { + FixMyStreet::override_config { + ALLOWED_COBRANDS => [ { 'tester' => '.' } ] + }, sub { + + $mech->clear_emails_ok; + + $mech->get_ok($REPORT_URL); + $mech->submit_form_ok({ with_fields => { + %problem_prepopulated, + problem_hide => 1, + }}); + $mech->base_unlike( qr{/report/}, 'redirected to front page' ); + + $report->discard_changes; + is $report->state, 'hidden', 'Is hidden'; + + ok $mech->email_count_is(0), "Email wasn't sent"; + + # reset + $report->update({ state => 'confirmed' }); + } + }; }; $mech->content_lacks('Posted anonymously', 'sanity check'); |