Mooeypoo has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/351699 )

Change subject: [experimental] Implement per-user notification blacklist with 
preference
......................................................................

[experimental] Implement per-user notification blacklist with preference

This is an experimental patch to suggest a correction to the underlying
patch at Ibf548da4aa600bd to use the block list in a preference rather
than a wiki page.

Bug: T150419
Change-Id: I72ee52a3d77592e9e77c0be134a2ea8b9565dbe0
---
M Hooks.php
M extension.json
M i18n/en.json
M includes/controller/NotificationController.php
4 files changed, 19 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/99/351699/1

diff --git a/Hooks.php b/Hooks.php
index c256093..011dcd3 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -483,6 +483,12 @@
                        ];
                }
 
+               $preferences['echo-mention-blacklist'] = [
+                       'type' => 'textarea',
+                       'label-message' => 'echo-pref-mention-blacklist',
+                       'section' => 'echo/blockmentionlist',
+               ];
+
                return true;
        }
 
diff --git a/extension.json b/extension.json
index 179a3ed..e5d16dc 100644
--- a/extension.json
+++ b/extension.json
@@ -664,8 +664,8 @@
                "EchoOnWikiBlacklist": {
                        "value": "Echo-blacklist"
                },
-               "EchoPerUserBlacklistFormat": {
-                       "value": "%s/Echo-blacklist"
+               "EchoPerUserBlacklist": {
+                       "value": true,
                },
                "EchoPerUserWhitelistFormat": {
                        "value": "%s/Echo-whitelist"
diff --git a/i18n/en.json b/i18n/en.json
index d5cac50..a34cf67 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -42,6 +42,7 @@
        "prefs-echosubscriptions": "Notify me about these events",
        "prefs-echocrosswiki": "Cross-wiki notifications",
        "prefs-newmessageindicator": "New message indicator",
+       "prefs-blockmentionlist": "Block list",
        "echo-pref-send-me": "Send me:",
        "echo-pref-send-to": "Send to:",
        "echo-pref-email-format": "Email format:",
@@ -54,6 +55,7 @@
        "echo-pref-email-format-html": "HTML",
        "echo-pref-email-format-plain-text": "Plain text",
        "echo-pref-cross-wiki-notifications": "Show notifications from other 
wikis",
+       "echo-pref-mention-blacklist": "List of usernames that are blacklisted 
from triggering a mention notifications.",
        "echo-pref-new-message-indicator": "Show talk page message indicator in 
my toolbar",
        "echo-pref-beta-feature-cross-wiki-message": "Enhanced notifications",
        "echo-pref-beta-feature-cross-wiki-description": "View and organize 
notifications more easily. Includes cross-wiki notifications, which lets you 
see messages from other wikis. (To receive cross-wiki notifications on a given 
wiki, you must activate the beta feature on that wiki.)",
diff --git a/includes/controller/NotificationController.php 
b/includes/controller/NotificationController.php
index 7985daf..c3f8428 100644
--- a/includes/controller/NotificationController.php
+++ b/includes/controller/NotificationController.php
@@ -210,7 +210,7 @@
                }
 
                if ( self::$blacklist === null ) {
-                       global $wgEchoAgentBlacklist, 
$wgEchoPerUserBlacklistFormat;
+                       global $wgEchoAgentBlacklist, $wgEchoPerUserBlacklist;
 
                        self::$blacklist = new EchoContainmentSet;
                        self::$blacklist->addArray( $wgEchoAgentBlacklist );
@@ -218,13 +218,14 @@
                        if ( $wikiBlacklist !== null ) {
                                self::$blacklist->add( $wikiBlacklist );
                        }
-                       if ( $wgEchoPerUserBlacklistFormat !== null ) {
-                               self::$blacklist->addOnWiki(
-                                       NS_USER,
-                                       sprintf( $wgEchoPerUserBlacklistFormat, 
$user->getName() ),
-                                       ObjectCache::getLocalClusterInstance(),
-                                       wfMemcKey( "echo_on_wiki_blacklist_" . 
$user->getId() )
-                               );
+                       if ( $wgEchoPerUserBlacklist ) {
+                               $userBlacklistOption = $user->getOption( 
'echo-mention-blacklist' );
+
+                               if ( $userBlacklistOption ) {
+                                       $blacklistedUsers = explode( "\n", 
$userBlacklistOption );
+
+                                       self::$blacklist->addArray( 
$blacklistedUsers );
+                               }
                        }
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/351699
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I72ee52a3d77592e9e77c0be134a2ea8b9565dbe0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to