Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/78781


Change subject: If the page is using LiquidThreads, add a new thread
......................................................................

If the page is using LiquidThreads, add a new thread

Bug: 52729
Change-Id: I9ee63a924e1afdd9f6c66d58168d2fed9e3dd586
---
M MassMessageJob.php
1 file changed, 36 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage 
refs/changes/81/78781/1

diff --git a/MassMessageJob.php b/MassMessageJob.php
index 87c8df7..eaf8d9f 100644
--- a/MassMessageJob.php
+++ b/MassMessageJob.php
@@ -91,28 +91,53 @@
                        }
                }
 
-               $this->editPage();
+               // See if we should use LiquidThreads
+               if ( class_exists( 'LqtDispatch' ) && LqtDispatch::isLqtPage( 
$title ) ) { // This is the same check that LQT uses internally
+                       $this->addLQTThread();
+               } else {
+                       $this->editPage();
+               }
 
                return true;
        }
 
        function editPage() {
+               $user = MassMessage::getMessengerUser();
+               $params = array(
+                       'action' => 'edit',
+                       'title' => $this->title->getPrefixedText(),
+                       'section' => 'new',
+                       'summary' => $this->params['subject'],
+                       'text' => $this->params['message'],
+                       'notminor' => true,
+                       'bot' => true,
+                       'token' => $user->getEditToken()
+               );
+
+               $this->makeAPIRequest( $params );
+       }
+
+       function addLQTThread() {
+               $user = MassMessage::getMessengerUser();
+               $params = array(
+                       'action' => 'threadaction',
+                       'threadaction' => 'newthread',
+                       'subject' => $this->params['subject'],
+                       'text' => $this->params['message'],
+                       'token' => $user->getEditToken()
+               ); // LQT will automatically mark the edit as bot if we're a bot
+
+               $this->makeAPIRequest( $params );
+       }
+
+       function makeAPIRequest( $params ) {
                global $wgUser, $wgRequest;
                $user = MassMessage::getMessengerUser();
                $wgUser = $user; // Is this safe? We need to do this for 
EditPage.php
                $api = new ApiMain(
                        new DerivativeRequest(
                                $wgRequest,
-                               array(
-                                       'action' => 'edit',
-                                       'title' => 
$this->title->getPrefixedText(),
-                                       'section' => 'new',
-                                       'summary' => $this->params['subject'],
-                                       'text' => $this->params['message'],
-                                       'notminor' => true,
-                                       'bot' => true,
-                                       'token' => $user->getEditToken()
-                               ),
+                               $params,
                                true // was posted?
                        ),
                        true // enable write?

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ee63a924e1afdd9f6c66d58168d2fed9e3dd586
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

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

Reply via email to