Auto topic subscriptions disabled by default, enabled only for new users when out of beta

Bug: T294398
Change-Id: I909caaebbb976624a16f15361d4ee232007ff506
This commit is contained in:
Bartosz Dziewoński 2021-11-09 22:33:59 +01:00
parent 90283b3a7e
commit 9adbbccad8
2 changed files with 9 additions and 2 deletions

View file

@ -497,7 +497,7 @@
"discussiontools-replytool": 1,
"discussiontools-sourcemodetoolbar": 1,
"discussiontools-topicsubscription": 1,
"discussiontools-autotopicsub": 1,
"discussiontools-autotopicsub": 0,
"discussiontools-abtest": ""
},
"config": {

View file

@ -201,10 +201,17 @@ class PreferenceHooks implements
* @return bool|void True or no return value to continue or false to abort
*/
public function onLocalUserCreated( $user, $autocreated ) {
// We want new users to be created with email-subscriptions to our notifications enabled
if ( !$autocreated ) {
$userOptionsManager = MediaWikiServices::getInstance()->getUserOptionsManager();
// We want new users to be created with email-subscriptions to our notifications enabled
$userOptionsManager->setOption( $user, 'echo-subscriptions-email-dt-subscription', true );
// The auto topic subscription feature is disabled by default for existing users, but
// we enable it for new users (T294398).
// This can only occur when the feature is available for everyone; when it's in beta,
// the new user won't have the beta enabled, so it'll never be available here.
if ( HookUtils::isFeatureAvailableToUser( $user, HookUtils::AUTOTOPICSUB ) ) {
$userOptionsManager->setOption( $user, 'discussiontools-' . HookUtils::AUTOTOPICSUB, 1 );
}
$user->saveSettings();
}
}