Migrate cookie hack users to beta feature

Bug: T277783
Change-Id: I455cab2acd0729b1c117b65cc1ede0ad9eb651cf
This commit is contained in:
Bartosz Dziewoński 2021-03-16 23:16:12 +01:00
parent 5938e97250
commit 2352fefb58
2 changed files with 10 additions and 0 deletions

View file

@ -50,6 +50,7 @@
{
"name": "config.json",
"config": {
"beta": "DiscussionToolsBeta",
"enable": "DiscussionToolsEnable"
}
},

View file

@ -30,6 +30,15 @@ if ( uri.query.dtdebug ) {
// so reply links are added on the server.
if ( !config.enable && !uri.query.dtenable ) {
mw.cookie.set( 'discussiontools-tempenable', 1 );
} else if ( config.enable && config.beta && mw.cookie.get( 'discussiontools-tempenable' ) ) {
// If they were using the cookie but we're available as a beta feature now:
if ( mw.user.options.get( 'discussiontools-betaenable' ) ) {
// Clear the cookie if the beta feature is enabled
mw.cookie.set( 'discussiontools-tempenable', null );
} else {
// Enable the beta feature if it isn't (cookie will be cleared the next time)
( new mw.Api() ).saveOption( 'discussiontools-betaenable', 1 );
}
}
module.exports = {