From 56e540c606ceebc57ba21c6efb9ac55a71aa0311 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Tue, 19 Mar 2024 10:22:07 -0400 Subject: [PATCH] Add optional parameter to show message if user is blocked. If a user or IP address is blocked from sending emails, they will not be able to access the Contact form. For our purposes of account vanishing, this is problematic because the user will not see any further instructions on how to proceed with account vanishing, and would instead see instructions for appealing the block. This patch provides a simple mechanism for showing a message if the account or IP is blocked (instead of the default block template), which may contain other instructions for the user in specific cases like ours. Bug: T343536 Change-Id: I77b4b049b07f9f1e729a9a0ca6b63a6d15343848 --- extension.json | 1 + includes/SpecialContact.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/extension.json b/extension.json index a011d56..2813c38 100644 --- a/extension.json +++ b/extension.json @@ -34,6 +34,7 @@ "NameReadonly": false, "EmailReadonly": false, "SubjectReadonly": false, + "UseCustomBlockMessage": false, "RLModules": [], "RLStyleModules": [], "AdditionalFields": { diff --git a/includes/SpecialContact.php b/includes/SpecialContact.php index fe53532..8268103 100644 --- a/includes/SpecialContact.php +++ b/includes/SpecialContact.php @@ -158,9 +158,16 @@ class SpecialContact extends UnlistedSpecialPage { // Blocked users cannot use the contact form if they're disabled from sending email. if ( $user->isBlockedFromEmailuser() ) { - // If the user is blocked from emailing users then there is a block - // @phan-suppress-next-line PhanTypeMismatchArgumentNullable - throw new UserBlockedError( $this->getUser()->getBlock() ); + $useCustomBlockMessage = $config['UseCustomBlockMessage'] ?? false; + if ( $useCustomBlockMessage ) { + $this->getOutput()->showErrorPage( $this->getFormSpecificMessageKey( 'contactpage-title' ), + $this->getFormSpecificMessageKey( 'contactpage-blocked-message' ) ); + return; + } else { + // If the user is blocked from emailing users then there is a block + // @phan-suppress-next-line PhanTypeMismatchArgumentNullable + throw new UserBlockedError( $this->getUser()->getBlock() ); + } } $this->getOutput()->setPageTitleMsg(