mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-09-23 18:30:06 +00:00
Track why mentions didn't happen
Right now we don't actually know how many times each of these cases happen so add some basic tracking so we can make some informed decisions. Bug: T135719 Change-Id: Id4d519aefe96ecca2e3c51dd1c8128de70d0caac
This commit is contained in:
parent
a1279d3a5c
commit
f51256845c
|
@ -144,26 +144,39 @@ abstract class EchoDiscussionParser {
|
|||
}
|
||||
$mentionedUsers = array();
|
||||
$count = 0;
|
||||
$stats = RequestContext::getMain()->getStats();
|
||||
|
||||
foreach ( $links[NS_USER] as $dbk => $page_id ) {
|
||||
$user = User::newFromName( $dbk );
|
||||
|
||||
// we should not add user to 'mention' notification list if
|
||||
// 1. the user name is not valid
|
||||
// 2. the user mentions themselves
|
||||
// 3. the user is the owner of the talk page
|
||||
// 4. user is anonymous
|
||||
if (
|
||||
!$user || $user->isAnon() || $user->getId() == $revision->getUser() ||
|
||||
( $title->getNamespace() === NS_USER_TALK && $title->getDBkey() === $dbk )
|
||||
) {
|
||||
if ( !$user ) {
|
||||
$stats->increment( 'echo.event.mention.error.invalidUser' );
|
||||
continue;
|
||||
}
|
||||
// 2. the user mentions themselves
|
||||
if ( $user->getId() == $revision->getUser() ) {
|
||||
$stats->increment( 'echo.event.mention.error.sameUser' );
|
||||
continue;
|
||||
}
|
||||
// 3. the user is the owner of the talk page
|
||||
if ( $title->getNamespace() === NS_USER_TALK && $title->getDBkey() === $dbk ) {
|
||||
$stats->increment( 'echo.event.mention.error.ownPage' );
|
||||
continue;
|
||||
}
|
||||
// 4. user is anonymous
|
||||
if ( $user->isAnon() ) {
|
||||
$stats->increment( 'echo.event.mention.error.anonUser' );
|
||||
continue;
|
||||
}
|
||||
|
||||
$mentionedUsers[$user->getId()] = $user->getId();
|
||||
$count++;
|
||||
// If more than 50 users are being pinged this is likely a spam/attack vector
|
||||
// Don't send any mention notifications.
|
||||
if ( $count > 50 ) {
|
||||
$stats->increment( 'echo.event.mention.error.tooMany' );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue