Skip to content

Commit e7772fe

Browse files
authored
Correct verf email problem (#609)
* Remove duplicate code and merge for proper DB entry * Reject additional API errors for invalid name * Convert async to sync per Phab T325692
1 parent bc916ca commit e7772fe

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

app/Http/Controllers/Appeal/PublicAppealController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function store(Request $request)
9898
'ua' => $ua . ' ' . $lang,
9999
]);
100100

101-
GetBlockDetailsJob::dispatch($appeal);
101+
GetBlockDetailsJob::dispatchNow($appeal);
102102

103103
return $appeal;
104104
});

app/Jobs/VerifyBlockJob.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function handle()
3838
{
3939
// check if the user can be e-mailed according to MediaWiki API
4040
if (!MediaWikiRepository::getApiForTarget($this->appeal->wiki)->getMediaWikiExtras()->canEmail($this->appeal->getWikiEmailUsername())) {
41+
$this->appeal->update(['user_verified'=>-1]);
4142
return;
4243
}
4344

@@ -62,15 +63,10 @@ public function handle()
6263

6364

6465
try {
65-
if (!MediaWikiRepository::getApiForTarget($appeal->wiki)->getMediaWikiExtras()->canEmail($appeal->getWikiEmailUsername())) {
66-
//user has not set an email on wiki
67-
$this->appeal->update(['user_verified'=>-1]);
68-
return;
69-
}
7066
$result = MediaWikiRepository::getApiForTarget($this->appeal->wiki)->getMediaWikiExtras()->sendEmail($this->appeal->getWikiEmailUsername(), $title, $message);
7167

7268
if (!$result) {
73-
throw new RuntimeException('Failed sending an e-mail');
69+
throw new RuntimeException('Failed sending an e-mail: No result from MW API');
7470
}
7571
} catch (Exception $exception) {
7672
// wrap exception to add appeal number to log

app/Services/MediaWiki/Implementation/RealMediaWikiExtras.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public function getBlockInfo(string $target, int $appealId = -1, string $searchK
8282
]
8383
));
8484
} catch (Exception $e) {
85+
if (str_contains($e->getMessage(), "Invalid value")) {
86+
//UTRS can't recognize this as an IP and MW is rejecting the username
87+
return null;
88+
}
8589
Log::error("MediaWiki API Failure: " . $e->getMessage() . " on appealID #". $appealId);
8690
throw $e;
8791
}

0 commit comments

Comments
 (0)