mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 15:36:58 +00:00
Namespace some more classes
Change-Id: If1405788a4adb550e8a7e8c58b0c2c55cf10ea67
This commit is contained in:
parent
1bc5b6daf8
commit
e576cbdca0
|
@ -1057,16 +1057,10 @@
|
|||
"manifest_version": 2,
|
||||
"AutoloadClasses": {
|
||||
"BackfillUnreadWikis": "maintenance/backfillUnreadWikis.php",
|
||||
"Bundleable": "includes/Bundleable.php",
|
||||
"Bundler": "includes/Bundler.php",
|
||||
"EchoArrayList": "includes/EchoArrayList.php",
|
||||
"EchoAttributeManager": "includes/AttributeManager.php",
|
||||
"MediaWiki\\Extension\\Notifications\\AttributeManager": "includes/AttributeManager.php",
|
||||
"EchoCachedList": "includes/EchoCachedList.php",
|
||||
"EchoCallbackIterator": "includes/Iterator/CallbackIterator.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Iterator\\CallbackIterator": "includes/Iterator/CallbackIterator.php",
|
||||
"EchoContainmentList": "includes/EchoContainmentList.php",
|
||||
"EchoContainmentSet": "includes/EchoContainmentSet.php",
|
||||
"EchoDataOutputFormatter": "includes/DataOutputFormatter.php",
|
||||
"EchoDeferredMarkAsDeletedUpdate": "includes/DeferredMarkAsDeletedUpdate.php",
|
||||
"EchoDiffGroup": "includes/EchoDiffGroup.php",
|
||||
|
@ -1075,8 +1069,6 @@
|
|||
"MediaWiki\\Extension\\Notifications\\DiscussionParser": "includes/DiscussionParser.php",
|
||||
"EchoEditUserTalkPresentationModel": "includes/Formatters/EchoEditUserTalkPresentationModel.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Formatters\\EchoEditUserTalkPresentationModel": "includes/Formatters/EchoEditUserTalkPresentationModel.php",
|
||||
"EchoEmailFormat": "includes/EmailFormat.php",
|
||||
"EchoEmailFrequency": "includes/EmailFrequency.php",
|
||||
"EchoEvent": "includes/Model/Event.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Model\\Event": "includes/Model/Event.php",
|
||||
"EchoEventPresentationModel": "includes/Formatters/EchoEventPresentationModel.php",
|
||||
|
@ -1093,10 +1085,8 @@
|
|||
"MediaWiki\\Extension\\Notifications\\Mapper\\NotificationMapper": "includes/Mapper/NotificationMapper.php",
|
||||
"EchoNotifier": "includes/Notifier.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Notifier": "includes/Notifier.php",
|
||||
"EchoOnWikiList": "includes/EchoOnWikiList.php",
|
||||
"EchoPresentationModelSection": "includes/Formatters/EchoPresentationModelSection.php",
|
||||
"MediaWiki\\Extension\\Notifications\\Formatters\\EchoPresentationModelSection": "includes/Formatters/EchoPresentationModelSection.php",
|
||||
"EchoSeenTime": "includes/SeenTime.php",
|
||||
"EchoServices": "includes/EchoServices.php",
|
||||
"EchoSummaryParser": "includes/EchoSummaryParser.php",
|
||||
"EchoSuppressionRowUpdateGenerator": "includes/schemaUpdate.php",
|
||||
|
@ -1106,7 +1096,6 @@
|
|||
"GenerateSampleNotifications": "maintenance/generateSampleNotifications.php",
|
||||
"MWEchoDbFactory": "includes/DbFactory.php",
|
||||
"MediaWiki\\Extension\\Notifications\\DbFactory": "includes/DbFactory.php",
|
||||
"MWEchoEmailBatch": "includes/EmailBatch.php",
|
||||
"MWEchoEventLogging": "includes/EventLogging.php",
|
||||
"MWEchoNotifUser": "includes/NotifUser.php",
|
||||
"ProcessEchoEmailBatch": "maintenance/processEchoEmailBatch.php",
|
||||
|
@ -1126,6 +1115,10 @@
|
|||
"EchoAbstractMapperStub": "tests/phpunit/Mapper/EchoAbstractMapperStub.php",
|
||||
"EchoExecuteFirstArgumentStub": "tests/phpunit/Mapper/EchoExecuteFirstArgumentStub.php"
|
||||
},
|
||||
"TestAutoloadNamespaces": {
|
||||
"MediaWiki\\Extension\\Notifications\\Test\\": "tests/phpunit/",
|
||||
"MediaWiki\\Extension\\Notifications\\Test\\Integration\\": "tests/phpunit/integration/"
|
||||
},
|
||||
"ServiceWiringFiles": [
|
||||
"ServiceWiring.php"
|
||||
],
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace MediaWiki\Extension\Notifications\Api;
|
|||
// This is a GET module, not a POST module, for multi-DC support. See T222851.
|
||||
// Note that this module doesn't write to the database, only to the seentime cache.
|
||||
use ApiBase;
|
||||
use EchoSeenTime;
|
||||
use MediaWiki\Extension\Notifications\SeenTime;
|
||||
use Wikimedia\ParamValidator\ParamValidator;
|
||||
|
||||
class ApiEchoMarkSeen extends ApiBase {
|
||||
|
@ -21,7 +21,7 @@ class ApiEchoMarkSeen extends ApiBase {
|
|||
|
||||
$params = $this->extractRequestParams();
|
||||
$timestamp = wfTimestamp( TS_MW );
|
||||
$seenTime = EchoSeenTime::newFromUser( $user );
|
||||
$seenTime = SeenTime::newFromUser( $user );
|
||||
$seenTime->setTime( $timestamp, $params['type'] );
|
||||
|
||||
if ( $params['timestampFormat'] === 'ISO_8601' ) {
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace MediaWiki\Extension\Notifications\Api;
|
|||
use ApiBase;
|
||||
use ApiQuery;
|
||||
use ApiQueryBase;
|
||||
use Bundler;
|
||||
use Config;
|
||||
use EchoDataOutputFormatter;
|
||||
use EchoForeignNotifications;
|
||||
use EchoSeenTime;
|
||||
use EchoServices;
|
||||
use MediaWiki\Extension\Notifications\AttributeManager;
|
||||
use MediaWiki\Extension\Notifications\Bundler;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
|
||||
use MediaWiki\Extension\Notifications\Model\Notification;
|
||||
use MediaWiki\Extension\Notifications\SeenTime;
|
||||
use MediaWiki\WikiMap\WikiMap;
|
||||
use MWEchoNotifUser;
|
||||
use Title;
|
||||
|
@ -377,7 +377,7 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
*/
|
||||
protected function getPropSeenTime( User $user, array $sections, $groupBySection ) {
|
||||
$result = [];
|
||||
$seenTimeHelper = EchoSeenTime::newFromUser( $user );
|
||||
$seenTimeHelper = SeenTime::newFromUser( $user );
|
||||
|
||||
if ( $groupBySection ) {
|
||||
foreach ( $sections as $section ) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
/**
|
||||
* Implements the EchoContainmentList interface for php arrays. Possible source
|
||||
* Implements the ContainmentList interface for php arrays. Possible source
|
||||
* of arrays includes $wg* global variables initialized from extensions or global
|
||||
* wiki config.
|
||||
*/
|
||||
class EchoArrayList implements EchoContainmentList {
|
||||
class ArrayList implements ContainmentList {
|
||||
/**
|
||||
* @var array
|
||||
*/
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
/**
|
||||
* Indicates that an object can be bundled.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
class Bundler {
|
||||
|
||||
private function sort( &$array ) {
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use UnexpectedValueException;
|
||||
use WANObjectCache;
|
||||
|
||||
/**
|
||||
* Caches an EchoContainmentList within WANObjectCache to prevent needing
|
||||
* Caches an ContainmentList within WANObjectCache to prevent needing
|
||||
* to load the nested list from a potentially slow source (mysql, etc).
|
||||
*/
|
||||
class EchoCachedList implements EchoContainmentList {
|
||||
class CachedList implements ContainmentList {
|
||||
private const ONE_WEEK = 4233600;
|
||||
|
||||
/** @var WANObjectCache */
|
||||
protected $cache;
|
||||
/** @var string */
|
||||
protected $partialCacheKey;
|
||||
/** @var EchoContainmentList */
|
||||
/** @var ContainmentList */
|
||||
protected $nestedList;
|
||||
/** @var int */
|
||||
protected $timeout;
|
||||
|
@ -22,13 +27,13 @@ class EchoCachedList implements EchoContainmentList {
|
|||
* @param WANObjectCache $cache Bag to stored cached data in.
|
||||
* @param string $partialCacheKey Partial cache key, $nestedList->getCacheKey() will be appended
|
||||
* to this to construct the cache key used.
|
||||
* @param EchoContainmentList $nestedList The nested EchoContainmentList to cache the result of.
|
||||
* @param ContainmentList $nestedList The nested EchoContainmentList to cache the result of.
|
||||
* @param int $timeout How long in seconds to cache the nested list, defaults to 1 week.
|
||||
*/
|
||||
public function __construct(
|
||||
WANObjectCache $cache,
|
||||
$partialCacheKey,
|
||||
EchoContainmentList $nestedList,
|
||||
ContainmentList $nestedList,
|
||||
$timeout = self::ONE_WEEK
|
||||
) {
|
||||
$this->cache = $cache;
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
/**
|
||||
* Interface providing list of contained values and an optional cache key to go along with it.
|
||||
*/
|
||||
interface EchoContainmentList {
|
||||
interface ContainmentList {
|
||||
/**
|
||||
* @return string[] The values contained within this list.
|
||||
*/
|
|
@ -1,15 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use BadMethodCallException;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Preferences\MultiUsernameFilter;
|
||||
use User;
|
||||
use WANObjectCache;
|
||||
|
||||
/**
|
||||
* Utilizes EchoContainmentList interface to provide a fluent interface to whitelist/blacklist
|
||||
* Utilizes ContainmentList interface to provide a fluent interface to whitelist/blacklist
|
||||
* from multiple sources like global variables, wiki pages, etc.
|
||||
*
|
||||
* Initialize:
|
||||
* $cache = ObjectCache::getLocalClusterInstance();
|
||||
* $set = new EchoContainmentSet;
|
||||
* $set = new ContainmentSet;
|
||||
* $set->addArray( $wgSomeGlobalParameter );
|
||||
* $set->addOnWiki( NS_USER, 'Foo/bar-baz', $cache, 'some_user_specific_cache_key' );
|
||||
*
|
||||
|
@ -18,9 +23,9 @@ use MediaWiki\Preferences\MultiUsernameFilter;
|
|||
* ...
|
||||
* }
|
||||
*/
|
||||
class EchoContainmentSet {
|
||||
class ContainmentSet {
|
||||
/**
|
||||
* @var EchoContainmentList[]
|
||||
* @var ContainmentList[]
|
||||
*/
|
||||
protected $lists = [];
|
||||
|
||||
|
@ -37,11 +42,11 @@ class EchoContainmentSet {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add an EchoContainmentList to the set of lists checked by self::contains()
|
||||
* Add an ContainmentList to the set of lists checked by self::contains()
|
||||
*
|
||||
* @param EchoContainmentList $list
|
||||
* @param ContainmentList $list
|
||||
*/
|
||||
public function add( EchoContainmentList $list ) {
|
||||
public function add( ContainmentList $list ) {
|
||||
$this->lists[] = $list;
|
||||
}
|
||||
|
||||
|
@ -51,7 +56,7 @@ class EchoContainmentSet {
|
|||
* @param array $list
|
||||
*/
|
||||
public function addArray( array $list ) {
|
||||
$this->add( new EchoArrayList( $list ) );
|
||||
$this->add( new ArrayList( $list ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,12 +108,12 @@ class EchoContainmentSet {
|
|||
public function addOnWiki(
|
||||
$namespace, $title, WANObjectCache $cache = null, $cacheKeyPrefix = ''
|
||||
) {
|
||||
$list = new EchoOnWikiList( $namespace, $title );
|
||||
$list = new OnWikiList( $namespace, $title );
|
||||
if ( $cache ) {
|
||||
if ( $cacheKeyPrefix === '' ) {
|
||||
throw new BadMethodCallException( 'Cache requires providing a cache key prefix.' );
|
||||
}
|
||||
$list = new EchoCachedList( $cache, $cacheKeyPrefix, $list );
|
||||
$list = new CachedList( $cache, $cacheKeyPrefix, $list );
|
||||
}
|
||||
$this->add( $list );
|
||||
}
|
|
@ -3,20 +3,20 @@
|
|||
namespace MediaWiki\Extension\Notifications\Controller;
|
||||
|
||||
use DeferredUpdates;
|
||||
use EchoCachedList;
|
||||
use EchoContainmentList;
|
||||
use EchoContainmentSet;
|
||||
use EchoOnWikiList;
|
||||
use EchoServices;
|
||||
use InvalidArgumentException;
|
||||
use Iterator;
|
||||
use MapCacheLRU;
|
||||
use MediaWiki\Extension\Notifications\AttributeManager;
|
||||
use MediaWiki\Extension\Notifications\CachedList;
|
||||
use MediaWiki\Extension\Notifications\ContainmentList;
|
||||
use MediaWiki\Extension\Notifications\ContainmentSet;
|
||||
use MediaWiki\Extension\Notifications\Hooks\HookRunner;
|
||||
use MediaWiki\Extension\Notifications\Iterator\FilteredSequentialIterator;
|
||||
use MediaWiki\Extension\Notifications\Jobs\NotificationDeleteJob;
|
||||
use MediaWiki\Extension\Notifications\Jobs\NotificationJob;
|
||||
use MediaWiki\Extension\Notifications\Model\Event;
|
||||
use MediaWiki\Extension\Notifications\OnWikiList;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionStore;
|
||||
|
@ -61,7 +61,7 @@ class NotificationController {
|
|||
/**
|
||||
* Echo event agent per wiki blacklist
|
||||
*
|
||||
* @var EchoContainmentList|null
|
||||
* @var ContainmentList|null
|
||||
*/
|
||||
protected static $wikiBlacklist;
|
||||
|
||||
|
@ -73,7 +73,7 @@ class NotificationController {
|
|||
protected static $whitelistByUser;
|
||||
|
||||
/**
|
||||
* Returns the count passed in, or MWEchoNotifUser::MAX_BADGE_COUNT + 1,
|
||||
* Returns the count passed in, or NotifUser::MAX_BADGE_COUNT + 1,
|
||||
* whichever is less.
|
||||
*
|
||||
* @param int $count
|
||||
|
@ -307,7 +307,7 @@ class NotificationController {
|
|||
|
||||
// Ensure we have a blacklist for the user
|
||||
if ( !self::$blacklistByUser->has( (string)$user->getId() ) ) {
|
||||
$blacklist = new EchoContainmentSet( $user );
|
||||
$blacklist = new ContainmentSet( $user );
|
||||
|
||||
// Add the config setting
|
||||
$blacklist->addArray( $wgEchoAgentBlacklist );
|
||||
|
@ -347,7 +347,7 @@ class NotificationController {
|
|||
self::$mutedPageLinkedTitlesCache = new MapCacheLRU( self::$maxUsersTitleCacheSize );
|
||||
}
|
||||
if ( !self::$mutedPageLinkedTitlesCache->has( (string)$user->getId() ) ) {
|
||||
$pageLinkedTitleMutedList = new EchoContainmentSet( $user );
|
||||
$pageLinkedTitleMutedList = new ContainmentSet( $user );
|
||||
$pageLinkedTitleMutedList->addTitleIDsFromUserOption(
|
||||
'echo-notifications-page-linked-title-muted-list'
|
||||
);
|
||||
|
@ -359,7 +359,7 @@ class NotificationController {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return EchoContainmentList|null
|
||||
* @return ContainmentList|null
|
||||
*/
|
||||
protected static function getWikiBlacklist() {
|
||||
global $wgEchoOnWikiBlacklist;
|
||||
|
@ -368,10 +368,10 @@ class NotificationController {
|
|||
}
|
||||
if ( self::$wikiBlacklist === null ) {
|
||||
$clusterCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
||||
self::$wikiBlacklist = new EchoCachedList(
|
||||
self::$wikiBlacklist = new CachedList(
|
||||
$clusterCache,
|
||||
$clusterCache->makeKey( "echo_on_wiki_blacklist" ),
|
||||
new EchoOnWikiList( NS_MEDIAWIKI, $wgEchoOnWikiBlacklist )
|
||||
new OnWikiList( NS_MEDIAWIKI, $wgEchoOnWikiBlacklist )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ class NotificationController {
|
|||
|
||||
// Ensure we have a whitelist for the user
|
||||
if ( !self::$whitelistByUser->has( (string)$userId ) ) {
|
||||
$whitelist = new EchoContainmentSet( $user );
|
||||
$whitelist = new ContainmentSet( $user );
|
||||
self::$whitelistByUser->set( (string)$userId, $whitelist );
|
||||
$whitelist->addOnWiki(
|
||||
NS_USER,
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use BatchRowIterator;
|
||||
use Language;
|
||||
use MailAddress;
|
||||
use MediaWiki\Extension\Notifications\Formatters\EchoHtmlDigestEmailFormatter;
|
||||
use MediaWiki\Extension\Notifications\Formatters\EchoPlainTextDigestEmailFormatter;
|
||||
use MediaWiki\Extension\Notifications\Mapper\EventMapper;
|
||||
|
@ -8,12 +12,17 @@ use MediaWiki\Extension\Notifications\Model\Event;
|
|||
use MediaWiki\Languages\LanguageFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\UserOptionsManager;
|
||||
use MWEchoEventLogging;
|
||||
use MWEchoNotifUser;
|
||||
use stdClass;
|
||||
use User;
|
||||
use UserMailer;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
/**
|
||||
* Handle user email batch ( daily/ weekly )
|
||||
*/
|
||||
class MWEchoEmailBatch {
|
||||
class EmailBatch {
|
||||
|
||||
/**
|
||||
* @var User the user to be notified
|
||||
|
@ -77,14 +86,14 @@ class MWEchoEmailBatch {
|
|||
* 1 - once everyday
|
||||
* 7 - once every 7 days
|
||||
* @param int $userId
|
||||
* @param bool $enforceFrequency Whether or not email sending frequency should
|
||||
* @param bool $enforceFrequency Whether email sending frequency should
|
||||
* be enforced.
|
||||
*
|
||||
* When true, today's notifications won't be returned if they are
|
||||
* configured to go out tonight or at the end of the week.
|
||||
*
|
||||
* When false, all pending notifications will be returned.
|
||||
* @return MWEchoEmailBatch|false
|
||||
* @return EmailBatch|false
|
||||
*/
|
||||
public static function newFromUserId( $userId, $enforceFrequency = true ) {
|
||||
$user = User::newFromId( (int)$userId );
|
||||
|
@ -324,7 +333,7 @@ class MWEchoEmailBatch {
|
|||
global $wgPasswordSender, $wgNoReplyAddress;
|
||||
|
||||
if ( $this->userOptionsManager->getOption( $this->mUser, 'echo-email-frequency' )
|
||||
== EchoEmailFrequency::WEEKLY_DIGEST
|
||||
== EmailFrequency::WEEKLY_DIGEST
|
||||
) {
|
||||
$frequency = 'weekly';
|
||||
$emailDeliveryMode = 'weekly_digest';
|
||||
|
@ -342,7 +351,7 @@ class MWEchoEmailBatch {
|
|||
}
|
||||
|
||||
$format = MWEchoNotifUser::newFromUser( $this->mUser )->getEmailFormat();
|
||||
if ( $format == EchoEmailFormat::HTML ) {
|
||||
if ( $format == EmailFormat::HTML ) {
|
||||
$htmlEmailDigestFormatter = new EchoHtmlDigestEmailFormatter( $this->mUser, $this->language, $frequency );
|
||||
$htmlContent = $htmlEmailDigestFormatter->format( $this->events, 'email' );
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
class EchoEmailFormat {
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
class EmailFormat {
|
||||
public const HTML = 'html';
|
||||
public const PLAIN_TEXT = 'plain-text';
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
class EchoEmailFrequency {
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
class EmailFrequency {
|
||||
/**
|
||||
* Never send email notifications
|
||||
*/
|
||||
|
|
|
@ -6,9 +6,6 @@ use ApiModuleManager;
|
|||
use Config;
|
||||
use Content;
|
||||
use DeferredUpdates;
|
||||
use EchoEmailFormat;
|
||||
use EchoEmailFrequency;
|
||||
use EchoSeenTime;
|
||||
use EchoServices;
|
||||
use EchoUserLocator;
|
||||
use EmailNotification;
|
||||
|
@ -303,14 +300,14 @@ class Hooks implements
|
|||
|
||||
// Show email frequency options
|
||||
$freqOptions = [
|
||||
'echo-pref-email-frequency-never' => EchoEmailFrequency::NEVER,
|
||||
'echo-pref-email-frequency-immediately' => EchoEmailFrequency::IMMEDIATELY,
|
||||
'echo-pref-email-frequency-never' => EmailFrequency::NEVER,
|
||||
'echo-pref-email-frequency-immediately' => EmailFrequency::IMMEDIATELY,
|
||||
];
|
||||
// Only show digest options if email batch is enabled
|
||||
if ( $wgEchoEnableEmailBatch ) {
|
||||
$freqOptions += [
|
||||
'echo-pref-email-frequency-daily' => EchoEmailFrequency::DAILY_DIGEST,
|
||||
'echo-pref-email-frequency-weekly' => EchoEmailFrequency::WEEKLY_DIGEST,
|
||||
'echo-pref-email-frequency-daily' => EmailFrequency::DAILY_DIGEST,
|
||||
'echo-pref-email-frequency-weekly' => EmailFrequency::WEEKLY_DIGEST,
|
||||
];
|
||||
}
|
||||
$preferences['echo-email-frequency'] = [
|
||||
|
@ -359,12 +356,12 @@ class Hooks implements
|
|||
// Email format
|
||||
$preferences['echo-email-format'] = [
|
||||
'type' => 'select',
|
||||
'default' => EchoEmailFormat::HTML,
|
||||
'default' => EmailFormat::HTML,
|
||||
'label-message' => 'echo-pref-email-format',
|
||||
'section' => 'echo/emailsettings',
|
||||
'options-messages' => [
|
||||
'echo-pref-email-format-html' => EchoEmailFormat::HTML,
|
||||
'echo-pref-email-format-plain-text' => EchoEmailFormat::PLAIN_TEXT,
|
||||
'echo-pref-email-format-html' => EmailFormat::HTML,
|
||||
'echo-pref-email-format-plain-text' => EmailFormat::PLAIN_TEXT,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
@ -714,7 +711,7 @@ class Hooks implements
|
|||
] );
|
||||
}
|
||||
|
||||
$seenTime = EchoSeenTime::newFromUser( $user );
|
||||
$seenTime = SeenTime::newFromUser( $user );
|
||||
|
||||
// Set seen time to UNIX epoch, so initially all notifications are unseen.
|
||||
$seenTime->setTime( wfTimestamp( TS_MW, 1 ), 'all' );
|
||||
|
@ -1017,7 +1014,7 @@ class Hooks implements
|
|||
$msgNotificationTimestamp = $notifUser->getLastUnreadMessageTime();
|
||||
$alertNotificationTimestamp = $notifUser->getLastUnreadAlertTime();
|
||||
|
||||
$seenTime = EchoSeenTime::newFromUser( $user );
|
||||
$seenTime = SeenTime::newFromUser( $user );
|
||||
if ( $title->isSpecial( 'Notifications' ) ) {
|
||||
// If this is the Special:Notifications page, seenTime to now
|
||||
$seenTime->setTime( wfTimestamp( TS_MW ), AttributeManager::ALL );
|
||||
|
@ -1222,7 +1219,7 @@ class Hooks implements
|
|||
public function onOutputPageCheckLastModified( &$modifiedTimes, $out ) {
|
||||
$req = $out->getRequest();
|
||||
if ( $req->getRawVal( 'action' ) === 'raw' || $req->getRawVal( 'action' ) === 'render' ) {
|
||||
// Optimisation: Avoid expensive EchoSeenTime compute on non-skin responses (T279213)
|
||||
// Optimisation: Avoid expensive SeenTime compute on non-skin responses (T279213)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1234,8 +1231,8 @@ class Hooks implements
|
|||
$modifiedTimes['notifications-global'] = $lastUpdate;
|
||||
}
|
||||
|
||||
$modifiedTimes['notifications-seen-alert'] = EchoSeenTime::newFromUser( $user )->getTime( 'alert' );
|
||||
$modifiedTimes['notifications-seen-message'] = EchoSeenTime::newFromUser( $user )->getTime( 'message' );
|
||||
$modifiedTimes['notifications-seen-alert'] = SeenTime::newFromUser( $user )->getTime( 'alert' );
|
||||
$modifiedTimes['notifications-seen-message'] = SeenTime::newFromUser( $user )->getTime( 'message' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace MediaWiki\Extension\Notifications\Model;
|
||||
|
||||
use Bundleable;
|
||||
use EchoServices;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\Extension\Notifications\Bundleable;
|
||||
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
||||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\Hooks\HookRunner;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace MediaWiki\Extension\Notifications\Model;
|
||||
|
||||
use Bundleable;
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\Extension\Notifications\Bundleable;
|
||||
use MediaWiki\Extension\Notifications\Hooks\HookRunner;
|
||||
use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use MediaWiki\Extension\Notifications\AttributeManager;
|
||||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\EmailFormat;
|
||||
use MediaWiki\Extension\Notifications\Gateway\UserNotificationGateway;
|
||||
use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
|
||||
use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper;
|
||||
|
@ -681,7 +682,7 @@ class MWEchoNotifUser {
|
|||
return $this->userOptionsLookup->getOption( $this->mUser, 'echo-email-format' );
|
||||
}
|
||||
|
||||
return EchoEmailFormat::PLAIN_TEXT;
|
||||
return EmailFormat::PLAIN_TEXT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use EchoEmailFormat;
|
||||
use EchoServices;
|
||||
use MailAddress;
|
||||
use MediaWiki\Extension\Notifications\Formatters\EchoHtmlEmailFormatter;
|
||||
|
@ -11,7 +10,6 @@ use MediaWiki\Extension\Notifications\Hooks\HookRunner;
|
|||
use MediaWiki\Extension\Notifications\Model\Event;
|
||||
use MediaWiki\Extension\Notifications\Model\Notification;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MWEchoEmailBatch;
|
||||
use MWEchoEventLogging;
|
||||
use MWEchoNotifUser;
|
||||
use User;
|
||||
|
@ -97,7 +95,7 @@ class Notifier {
|
|||
if ( !$bundleHash ) {
|
||||
$bundleHash = md5( $event->getType() . '-' . $event->getId() );
|
||||
}
|
||||
MWEchoEmailBatch::addToQueue( $user->getId(), $event->getId(), $priority, $bundleHash );
|
||||
EmailBatch::addToQueue( $user->getId(), $event->getId(), $priority, $bundleHash );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -144,7 +142,7 @@ class Notifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( $emailFormat === EchoEmailFormat::HTML ) {
|
||||
if ( $emailFormat === EmailFormat::HTML ) {
|
||||
$htmlEmailFormatter = new EchoHtmlEmailFormatter( $user, $lang );
|
||||
$htmlContent = $htmlEmailFormatter->format( $event, 'email' );
|
||||
$multipartBody = [
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use TextContent;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* Implements EchoContainmentList interface for sourcing a list of items from a wiki
|
||||
* page. Uses the pages latest revision ID as cache key.
|
||||
* Implements ContainmentList interface for sourcing a list of items from a wiki
|
||||
* page. Uses the page's latest revision ID as cache key.
|
||||
*/
|
||||
class EchoOnWikiList implements EchoContainmentList {
|
||||
class OnWikiList implements ContainmentList {
|
||||
/**
|
||||
* @var Title|null A title object representing the page to source the list from,
|
||||
* or null if the page does not exist.
|
||||
* or null if the page does not exist.
|
||||
*/
|
||||
protected $title;
|
||||
|
|
@ -1,12 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications;
|
||||
|
||||
use BagOStuff;
|
||||
use CachedBagOStuff;
|
||||
use CentralIdLookup;
|
||||
use DeferredUpdates;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use ObjectCache;
|
||||
use UnexpectedValueException;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* A small wrapper around ObjectCache to manage
|
||||
* storing the last time a user has seen notifications
|
||||
*/
|
||||
class EchoSeenTime {
|
||||
class SeenTime {
|
||||
|
||||
/**
|
||||
* Allowed notification types
|
||||
|
@ -28,7 +37,7 @@ class EchoSeenTime {
|
|||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return EchoSeenTime
|
||||
* @return SeenTime
|
||||
*/
|
||||
public static function newFromUser( User $user ) {
|
||||
return new self( $user );
|
||||
|
@ -48,7 +57,7 @@ class EchoSeenTime {
|
|||
if ( $wrappedCache === null ) {
|
||||
$cacheConfig = MediaWikiServices::getInstance()->getMainConfig()->get( 'EchoSeenTimeCacheType' );
|
||||
if ( $cacheConfig === null ) {
|
||||
// EchoHooks::initEchoExtension sets EchoSeenTimeCacheType to $wgMainStash if it's
|
||||
// Hooks::initEchoExtension sets EchoSeenTimeCacheType to $wgMainStash if it's
|
||||
// null, so this can only happen if $wgMainStash is also null
|
||||
throw new UnexpectedValueException(
|
||||
'Either $wgEchoSeenTimeCacheType or $wgMainStash must be set'
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace MediaWiki\Extension\Notifications\Special;
|
||||
|
||||
use EchoDataOutputFormatter;
|
||||
use EchoSeenTime;
|
||||
use Html;
|
||||
use MediaWiki\Extension\Notifications\OOUI\LabelIconWidget;
|
||||
use MediaWiki\Extension\Notifications\SeenTime;
|
||||
use MWEchoEventLogging;
|
||||
use MWEchoNotifUser;
|
||||
use OOUI;
|
||||
|
@ -78,8 +78,7 @@ class SpecialNotifications extends SpecialPage {
|
|||
// Add the notifications to the page (interspersed with date headers)
|
||||
$dateHeader = '';
|
||||
$anyUnread = false;
|
||||
$echoSeenTime = EchoSeenTime::newFromUser( $user );
|
||||
$seenTime = $echoSeenTime->getTime();
|
||||
$seenTime = SeenTime::newFromUser( $user )->getTime();
|
||||
$notifArray = [];
|
||||
foreach ( $notif as $row ) {
|
||||
if ( !$row['*'] ) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\EmailBatch;
|
||||
|
||||
$IP = getenv( 'MW_INSTALL_PATH' );
|
||||
if ( $IP === false ) {
|
||||
|
@ -39,13 +40,13 @@ class ProcessEchoEmailBatch extends Maintenance {
|
|||
while ( $count === $batchSize ) {
|
||||
$count = 0;
|
||||
|
||||
$res = MWEchoEmailBatch::getUsersToNotify( $startUserId, $batchSize );
|
||||
$res = EmailBatch::getUsersToNotify( $startUserId, $batchSize );
|
||||
|
||||
$updated = false;
|
||||
foreach ( $res as $row ) {
|
||||
$userId = intval( $row->eeb_user_id );
|
||||
if ( $userId && $userId > $startUserId ) {
|
||||
$emailBatch = MWEchoEmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
|
||||
$emailBatch = EmailBatch::newFromUserId( $userId, !$ignoreConfiguredSchedule );
|
||||
if ( $emailBatch ) {
|
||||
$this->output( "processing user_Id " . $userId . " \n" );
|
||||
$emailBatch->process();
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications\Test;
|
||||
|
||||
use HashBagOStuff;
|
||||
use MediaWiki\Extension\Notifications\ArrayList;
|
||||
use MediaWiki\Extension\Notifications\CachedList;
|
||||
use MediaWiki\Extension\Notifications\ContainmentSet;
|
||||
use MediaWiki\Extension\Notifications\OnWikiList;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use WANObjectCache;
|
||||
|
||||
/**
|
||||
* @covers \EchoContainmentSet
|
||||
* @covers \MediaWiki\Extension\Notifications\ContainmentSet
|
||||
* @group Echo
|
||||
* @group Database
|
||||
*/
|
||||
class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
public function testGenericContains() {
|
||||
$list = new EchoContainmentSet( self::getTestUser()->getUser() );
|
||||
$list = new ContainmentSet( self::getTestUser()->getUser() );
|
||||
|
||||
$list->addArray( [ 'foo', 'bar' ] );
|
||||
$this->assertTrue( $list->contains( 'foo' ) );
|
||||
|
@ -30,13 +40,13 @@ class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|||
$inner = [ 'bing', 'bang' ];
|
||||
// We use a mock instead of the real thing for the $this->once() assertion
|
||||
// verifying that the cache doesn't just keep asking the inner object
|
||||
$list = $this->createMock( EchoArrayList::class );
|
||||
$list = $this->createMock( ArrayList::class );
|
||||
$list->expects( $this->once() )
|
||||
->method( 'getValues' )
|
||||
->willReturn( $inner );
|
||||
$list->method( 'getCacheKey' )->willReturn( '' );
|
||||
|
||||
$cached = new EchoCachedList( $wanCache, 'test_key', $list );
|
||||
$cached = new CachedList( $wanCache, 'test_key', $list );
|
||||
|
||||
// First run through should hit the main list, and save to innerCache
|
||||
$this->assertEquals( $inner, $cached->getValues() );
|
||||
|
@ -44,7 +54,7 @@ class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// Reinitialize to get a fresh instance that will pull directly from
|
||||
// innerCache without hitting the $list
|
||||
$freshCached = new EchoCachedList( $wanCache, 'test_key', $list );
|
||||
$freshCached = new CachedList( $wanCache, 'test_key', $list );
|
||||
$this->assertEquals( $inner, $freshCached->getValues() );
|
||||
}
|
||||
|
||||
|
@ -54,7 +64,7 @@ class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|||
public function testOnWikiList() {
|
||||
$this->editPage( 'User:Foo/Bar-baz', "abc\ndef\r\nghi\n\n\n" );
|
||||
|
||||
$list = new EchoOnWikiList( NS_USER, "Foo/Bar-baz" );
|
||||
$list = new OnWikiList( NS_USER, "Foo/Bar-baz" );
|
||||
$this->assertEquals(
|
||||
[ 'abc', 'def', 'ghi' ],
|
||||
$list->getValues()
|
||||
|
@ -62,7 +72,7 @@ class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testOnWikiListNonExistant() {
|
||||
$list = new EchoOnWikiList( NS_USER, "Some_Non_Existant_Page" );
|
||||
$list = new OnWikiList( NS_USER, "Some_Non_Existant_Page" );
|
||||
$this->assertEquals( [], $list->getValues() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\EmailFormat;
|
||||
use MediaWiki\Extension\Notifications\Gateway\UserNotificationGateway;
|
||||
use MediaWiki\Extension\Notifications\Mapper\NotificationMapper;
|
||||
use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper;
|
||||
|
@ -58,7 +59,7 @@ class MWEchoNotifUserTest extends MediaWikiIntegrationTestCase {
|
|||
$this->setMwGlobals( 'wgAllowHTMLEmail', true );
|
||||
$this->assertEquals( $notifUser->getEmailFormat(), $pref );
|
||||
$this->setMwGlobals( 'wgAllowHTMLEmail', false );
|
||||
$this->assertEquals( EchoEmailFormat::PLAIN_TEXT, $notifUser->getEmailFormat() );
|
||||
$this->assertEquals( EmailFormat::PLAIN_TEXT, $notifUser->getEmailFormat() );
|
||||
}
|
||||
|
||||
public function testMarkRead() {
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\Notifications\Test\Integration;
|
||||
|
||||
use MediaWiki\Extension\Notifications\ContainmentSet;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
use User;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass EchoContainmentSet
|
||||
* @coversDefaultClass \MediaWiki\Extension\Notifications\ContainmentSet
|
||||
*/
|
||||
class EchoContainmentSetTest extends MediaWikiIntegrationTestCase {
|
||||
class ContainmentSetTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::addTitleIDsFromUserOption
|
||||
|
@ -20,7 +25,7 @@ class EchoContainmentSetTest extends MediaWikiIntegrationTestCase {
|
|||
$userOptionsLookupMock = $this->createMock( UserOptionsLookup::class );
|
||||
$userOptionsLookupMock->method( 'getOption' )->willReturn( $prefData );
|
||||
$this->setService( 'UserOptionsLookup', $userOptionsLookupMock );
|
||||
$containmentSet = new EchoContainmentSet( $this->createMock( User::class ) );
|
||||
$containmentSet = new ContainmentSet( $this->createMock( User::class ) );
|
||||
$containmentSet->addTitleIDsFromUserOption( 'preference-name' );
|
||||
$this->assertSame( $expected, $containmentSet->contains( $contains ) );
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\Notifications\Bundler;
|
||||
use MediaWiki\Extension\Notifications\Model\Notification;
|
||||
|
||||
/**
|
||||
* @covers \Bundler
|
||||
* @covers \MediaWiki\Extension\Notifications\Bundler
|
||||
*/
|
||||
class BundlerTest extends MediaWikiUnitTestCase {
|
||||
|
||||
|
|
Loading…
Reference in a new issue