Mobrovac has submitted this change and it was merged.

Change subject: Emit user_block event.
......................................................................


Emit user_block event.

Bug: T122079
Change-Id: Ie56d846754af63afe322c963a69fa28ca9ae6074
---
M EventBus.hooks.php
M extension.json
2 files changed, 36 insertions(+), 1 deletion(-)

Approvals:
  CSteipp: Looks good to me, but someone else must approve
  Mobrovac: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index 0748491..6479739 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -290,6 +290,38 @@
        }
 
        /**
+        * Occurs after the request to block an IP or user has been processed
+        *
+        * @see https://www.mediawiki.org/wiki/Manual:Hooks/BlockIpComplete
+        *
+        * @param Block $block the Block object that was saved
+        * @param User $user the user who did the block (not the one being 
blocked)
+        */
+       public static function onBlockIpComplete( $block, $user ) {
+               $attrs = array();
+               $attrs['user_blocked'] = $block->getTarget()->getName();
+               if ( $block->mExpiry != 'infinity' ) {
+                       $attrs['expiry'] = $block->mExpiry;
+               }
+
+               $attrs['blocks'] = array(
+                       'name' => $block->mHideName,
+                       'email' => $block->prevents( 'sendemail' ),
+                       'user_talk' => $block->prevents( 'editownusertalk' ),
+                       'account_create' => $block->prevents( 'createaccount' ),
+               );
+               $attrs['reason'] = $block->mReason;
+               $attrs['user_id'] = $user->getId();
+               $attrs['user_text'] = $user->getName();
+
+               $event = self::createEvent( '/user_block/uri', 
'mediawiki.user_block', $attrs );
+
+               DeferredUpdates::addCallableUpdate( function() use ( $event ) {
+                       EventBus::getInstance()->send( array( $event ) );
+               } );
+       }
+
+       /**
         * Load our unit tests
         */
        public static function onUnitTestsList( array &$files ) {
diff --git a/extension.json b/extension.json
index e7f67e1..0e227c2 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "EventBus",
-       "version": "0.2.2",
+       "version": "0.2.3",
        "author": [
                "Eric Evans"
        ],
@@ -42,6 +42,9 @@
                "ArticlePurge": [
                        "EventBusHooks::onArticlePurge"
                ],
+               "BlockIpComplete": [
+                       "EventBusHooks::onBlockIpComplete"
+               ],
                "UnitTestsList": [
                        "EventBusHooks::onUnitTestsList"
                ]

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie56d846754af63afe322c963a69fa28ca9ae6074
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventBus
Gerrit-Branch: master
Gerrit-Owner: Ppchelko <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Eevans <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to