diff --git a/i18n/en.json b/i18n/en.json index e8f321542f..8e813351de 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -12,7 +12,7 @@ "action-createwiki-suppressrequest": "suppress wiki requests", "action-requestwiki": "request wikis", "createwiki": "Create a wiki", - "createwiki-close-email-body": "Hello,\n\nThis email is to inform you that your wiki has been closed.", + "createwiki-close-email-body": "Hello,\n\nThis email is to inform you that your wiki ([$2 $3]) has been closed.", "createwiki-close-email-sender": "noreply", "createwiki-close-email-subject": "Your wiki ($1) has been closed", "createwiki-comment-success": "Comment successfully added to this request.", diff --git a/i18n/qqq.json b/i18n/qqq.json index e8489debed..b1575895c2 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -19,7 +19,7 @@ "action-createwiki-suppressrequest": "{{doc-action|createwiki-suppressrequest}}", "action-requestwiki": "{{doc-action|requestwiki}}", "createwiki": "{{doc-special}}", - "createwiki-close-email-body": "Email body sent to the user when their wiki is closed.", + "createwiki-close-email-body": "Email body sent to the user when their wiki is closed.\n\nParameters:\n* $1: The database name of the wiki (e.g. metawiki)\n* $2: The URL to the wiki (e.g. meta.example.com)\n* $3: The sitename of the wiki", "createwiki-close-email-sender": "{{optional}}", "createwiki-close-email-subject": "Subject of the email sent when a wiki is closed.", "createwiki-comment-success": "Success message displayed when a comment is added to a wiki request.", diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 13d5fcc714..adf0959536 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -8,6 +8,7 @@ use Miraheze\CreateWiki\Services\CreateWikiDatabaseUtils; use Miraheze\CreateWiki\Services\CreateWikiDataStore; use Miraheze\CreateWiki\Services\CreateWikiNotificationsManager; +use Miraheze\CreateWiki\Services\CreateWikiValidator; use Miraheze\CreateWiki\Services\RemoteWikiFactory; use function date; use function strtotime; @@ -115,7 +116,7 @@ private function checkLastActivity( if ( $lastActivityTimestamp < date( 'YmdHis', strtotime( "-$closeTime days" ) ) ) { if ( $canWrite ) { $remoteWiki->markClosed(); - $this->notifyBureaucrats( $dbname ); + $this->notifyBureaucrats( $dbname, $remoteWiki ); $this->output( "$dbname has been closed. Last activity: $lastActivityTimestamp\n" ); } else { $this->output( "$dbname should be closed. Last activity: $lastActivityTimestamp\n" ); @@ -170,7 +171,7 @@ private function handleInactiveWiki( if ( $isInactive && $inactiveTimestamp < date( 'YmdHis', strtotime( "-$closeDays days" ) ) ) { if ( $canWrite ) { $remoteWiki->markClosed(); - $this->notifyBureaucrats( $dbname ); + $this->notifyBureaucrats( $dbname, $remoteWiki ); $this->output( "$dbname was marked as inactive on $inactiveTimestamp and is now closed. " . "Last activity: $lastActivityTimestamp.\n" @@ -219,13 +220,25 @@ private function handleClosedWiki( } } - private function notifyBureaucrats( string $dbname ): void { + private function notifyBureaucrats( string $dbname, RemoteWiki $remoteWiki ): void { + /** @var CreateWikiValidator $validator */ + $validator = $this->getServiceContainer()->get( 'CreateWikiValidator' ); + '@phan-var CreateWikiValidator $validator'; + + $url = $remoteWiki->getServerName() ?: $validator->getValidUrl( $dbname ); + + $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() ) + ->inContentLanguage(); + $notificationData = [ 'type' => 'closure', 'subject' => wfMessage( 'createwiki-close-email-subject', $dbname )->inContentLanguage()->text(), 'body' => [ - 'html' => wfMessage( 'createwiki-close-email-body' )->inContentLanguage()->parse(), - 'text' => wfMessage( 'createwiki-close-email-body' )->inContentLanguage()->text(), + 'html' => $body->parse(), + // Yes, this sends out the wikitext if the user is reading plaintext emails by default. + // However, I anticipate that those who are would be able to read (or at least glean the + // URLs from) the wikitext, especially if they are the bureaucrat of a wiki. + 'text' => $body->text(), ], ];