Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Mediawiki-CVS

[MediaWiki-commits] [Gerrit] If the page is using LiquidThreads, add a new thread - change (mediawiki...MassMessage)

 

 

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded


gerrit at wikimedia

Aug 11, 2013, 6:46 PM

Post #1 of 1 (4 views)
Permalink
[MediaWiki-commits] [Gerrit] If the page is using LiquidThreads, add a new thread - change (mediawiki...MassMessage)

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 <legoktm.wikipedia [at] gmail>

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

Wikipedia mediawiki-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.