diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | docs/customising/cobrand-module.md | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 8 | ||||
-rw-r--r-- | t/app/controller/contact.t | 28 |
5 files changed, 45 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5046eacf7..54851de5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - New features: - Dashboard now has update CSV export. #2249 - Allow cobrands to override searching by reference #2271 + - Allow cobrands to limit contact form to abuse reports only - Front end improvements: - Clearer relocation options while you’re reporting a problem #2238 - Admin improvements diff --git a/docs/customising/cobrand-module.md b/docs/customising/cobrand-module.md index fb771ab26..da9c9188f 100644 --- a/docs/customising/cobrand-module.md +++ b/docs/customising/cobrand-module.md @@ -101,5 +101,10 @@ name. <a href="{{ "/glossary/#state" | relative_url }}" class="glossary__link">state</a> of the report. Return 0 to disable this feature so that surveys are never sent. - + +* abuse_reports_only + + Limit the contact page to only accepting abuse reports for comments + and updates. This can be useful if you have another contact form and + want to prevent people using this. diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index aabeb650e..8850c37b4 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -100,6 +100,8 @@ sub determine_contact_type : Private { if ( $c->get_param("reject") && $c->user->has_permission_to(report_reject => $c->stash->{problem}->bodies_str_ids) ) { $c->stash->{rejecting_report} = 1; } + } elsif ( $c->cobrand->abuse_reports_only ) { + $c->detach( '/page_error_404_not_found' ); } return 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 836b6af58..e7ab77bfd 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -765,6 +765,14 @@ used in emails). sub contact_name { FixMyStreet->config('CONTACT_NAME') } sub contact_email { FixMyStreet->config('CONTACT_EMAIL') } +=item abuse_reports_only + +Return true if only abuse reports should be allowed from the contact form. + +=cut + +sub abuse_reports_only { 0; } + =item email_host Return if we are the virtual host that sends email for this cobrand diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 2cbdbc0da..254522b92 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -1,3 +1,13 @@ +package FixMyStreet::Cobrand::AbuseOnly; + +use base 'FixMyStreet::Cobrand::Default'; + +sub abuse_reports_only { 1; } + +1; + +package main; + use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; @@ -469,6 +479,24 @@ for my $test ( }; } +subtest 'check can limit contact to abuse reports' => sub { + FixMyStreet::override_config { + 'ALLOWED_COBRANDS' => [ 'abuseonly' ], + }, sub { + $mech->get( '/contact' ); + is $mech->res->code, 404, 'cannot visit contact page'; + $mech->get_ok( '/contact?id=' . $problem_main->id, 'can visit for abuse report' ); + + my $token = FixMyStreet::App->model("DB::Token")->create({ + scope => 'moderation', + data => { id => $problem_main->id } + }); + + $mech->get_ok( '/contact?m=' . $token->token, 'can visit for moderation complaint' ); + + } +}; + $problem_main->delete; done_testing(); |