mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Merge "Checking that revert notification is enabled before firing it"
This commit is contained in:
commit
88f7735c72
40
Hooks.php
40
Hooks.php
|
@ -184,6 +184,7 @@ class EchoHooks {
|
|||
* @return bool true in all cases
|
||||
*/
|
||||
public static function onArticleSaved( &$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status ) {
|
||||
global $wgEchoEnabledEvents;
|
||||
if ( $revision ) {
|
||||
EchoEvent::create( array(
|
||||
'type' => 'edit',
|
||||
|
@ -198,29 +199,30 @@ class EchoHooks {
|
|||
|
||||
// Handle the case of someone undoing an edit, either through the
|
||||
// 'undo' link in the article history or via the API.
|
||||
global $wgRequest;
|
||||
$undidRevId = $wgRequest->getVal( 'wpUndidRevision' );
|
||||
if ( $undidRevId ) {
|
||||
$undidRevision = Revision::newFromId( $undidRevId );
|
||||
if ( $undidRevision ) {
|
||||
$victimId = $undidRevision->getUser();
|
||||
if ( $victimId ) { // No notifications for anonymous users
|
||||
EchoEvent::create( array(
|
||||
'type' => 'reverted',
|
||||
'title' => $article->getTitle(),
|
||||
'extra' => array(
|
||||
'revid' => $revision->getId(),
|
||||
'reverted-user-id' => $victimId,
|
||||
'reverted-revision-id' => $undidRevId,
|
||||
'method' => 'undo',
|
||||
),
|
||||
'agent' => $user,
|
||||
) );
|
||||
if ( in_array( 'reverted', $wgEchoEnabledEvents ) ) {
|
||||
$undidRevId = $user->getRequest()->getVal( 'wpUndidRevision' );
|
||||
if ( $undidRevId ) {
|
||||
$undidRevision = Revision::newFromId( $undidRevId );
|
||||
if ( $undidRevision ) {
|
||||
$victimId = $undidRevision->getUser();
|
||||
if ( $victimId ) { // No notifications for anonymous users
|
||||
EchoEvent::create( array(
|
||||
'type' => 'reverted',
|
||||
'title' => $article->getTitle(),
|
||||
'extra' => array(
|
||||
'revid' => $revision->getId(),
|
||||
'reverted-user-id' => $victimId,
|
||||
'reverted-revision-id' => $undidRevId,
|
||||
'method' => 'undo',
|
||||
),
|
||||
'agent' => $user,
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue