Aaron Schulz has uploaded a new change for review.
https://gerrit.wikimedia.org/r/171455
Change subject: Route bounce job to the proper wiki queues
......................................................................
Route bounce job to the proper wiki queues
* This makes the calls to the User class methods work properly
Change-Id: I9f6881d7adb6471ac4fb79b7d0e099f4f8560342
---
M includes/ApiBounceHandler.php
M includes/ProcessBounceEmails.php
2 files changed, 31 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BounceHandler
refs/changes/55/171455/1
diff --git a/includes/ApiBounceHandler.php b/includes/ApiBounceHandler.php
index 403058e..4d21d14 100644
--- a/includes/ApiBounceHandler.php
+++ b/includes/ApiBounceHandler.php
@@ -6,10 +6,11 @@
class ApiBounceHandler extends ApiBase {
public function execute() {
global $wgBounceHandlerInternalIPs;
+
$requestIP = $this->getRequest()->getIP();
$inRangeIP = false;
- foreach( $wgBounceHandlerInternalIPs as
$BounceHandlerInternalIPs ) {
- if ( IP::isInRange( $requestIP,
$BounceHandlerInternalIPs ) ) {
+ foreach( $wgBounceHandlerInternalIPs as $internalIP ) {
+ if ( IP::isInRange( $requestIP, $internalIP ) ) {
$inRangeIP = true;
break;
}
@@ -21,15 +22,31 @@
$params = $this->extractRequestParams();
- $title = Title::newFromText( 'BounceHandler Job' );
- $job = new BounceHandlerJob( $title, $params );
- JobQueueGroup::singleton()->push( $job );
+ // Extract the wiki ID from the Verp address (also verifies the
hash)
+ $bounceProcessor = new ProcessBounceWithRegex();
+ $emailHeaders = $this->extractHeaders( $params['email'] );
+ $to = isset( $emailHeaders['to'] ) ? $emailHeaders['to'] : '';
+ $failedUser = strlen( $to ) ? $bounceProcessor->getUserDetails(
$to ) : array();
- $this->getResult()->addValue(
- null,
- $this->getModuleName(),
- array ( 'submitted' => 'job' )
- );
+ // Route the job to the wiki that the email was sent from.
+ // This way it can easily unconfirm the user's email using the
User methods.
+ if ( isset( $failedUser['wikiId'] ) ) {
+ $title = Title::newFromText( 'BounceHandler Job' );
+ $job = new BounceHandlerJob( $title, $params );
+ JobQueueGroup::singleton( $failedUser['wikiId']
)->push( $job );
+
+ $this->getResult()->addValue(
+ null,
+ $this->getModuleName(),
+ array ( 'submitted' => 'job' )
+ );
+ } else {
+ $this->getResult()->addValue(
+ null,
+ $this->getModuleName(),
+ array ( 'submitted' => 'failure' )
+ );
+ }
return true;
}
diff --git a/includes/ProcessBounceEmails.php b/includes/ProcessBounceEmails.php
index daa58d3..8f2a32f 100644
--- a/includes/ProcessBounceEmails.php
+++ b/includes/ProcessBounceEmails.php
@@ -84,8 +84,10 @@
* */
public function getUserDetails( $hashedEmail ) {
global $wgVERPalgorithm, $wgVERPsecret, $wgVERPAcceptTime;
- $currentTime = wfTimestamp();
+
$failedUser = array();
+
+ $currentTime = wfTimestamp();
preg_match( '~(.*?)@~', $hashedEmail, $hashedPart );
$hashedVERPPart = explode( '-', $hashedPart[1] );
$hashedData = $hashedVERPPart[0]. '-'. $hashedVERPPart[1]. '-'.
$hashedVERPPart[2]. '-'. $hashedVERPPart[3];
@@ -104,6 +106,7 @@
"Error: Hash validation failed. Expected hash
of $hashedData, got $hashedVERPPart[3]."
);
}
+
return $failedUser;
}
--
To view, visit https://gerrit.wikimedia.org/r/171455
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f6881d7adb6471ac4fb79b7d0e099f4f8560342
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BounceHandler
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits