mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Fix two issues with Phurl / Badges mail generation
Summary: - Phurl is missing a ReplyHandler / MailReceiver (all of this code should get cleaned up eventually, but I don't plan to get to it for a while). - Badges has a bad call. This should clean up some bad daemon tasks. Test Plan: Saw fewer daemon errors after these changes. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D14852
This commit is contained in:
parent
96fe8c0b83
commit
61a92df66e
5 changed files with 57 additions and 1 deletions
|
@ -2766,8 +2766,10 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
|
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
|
||||||
'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php',
|
'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php',
|
||||||
'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php',
|
'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php',
|
||||||
|
'PhabricatorPhurlURLMailReceiver' => 'applications/phurl/mail/PhabricatorPhurlURLMailReceiver.php',
|
||||||
'PhabricatorPhurlURLPHIDType' => 'applications/phurl/phid/PhabricatorPhurlURLPHIDType.php',
|
'PhabricatorPhurlURLPHIDType' => 'applications/phurl/phid/PhabricatorPhurlURLPHIDType.php',
|
||||||
'PhabricatorPhurlURLQuery' => 'applications/phurl/query/PhabricatorPhurlURLQuery.php',
|
'PhabricatorPhurlURLQuery' => 'applications/phurl/query/PhabricatorPhurlURLQuery.php',
|
||||||
|
'PhabricatorPhurlURLReplyHandler' => 'applications/phurl/mail/PhabricatorPhurlURLReplyHandler.php',
|
||||||
'PhabricatorPhurlURLSearchEngine' => 'applications/phurl/query/PhabricatorPhurlURLSearchEngine.php',
|
'PhabricatorPhurlURLSearchEngine' => 'applications/phurl/query/PhabricatorPhurlURLSearchEngine.php',
|
||||||
'PhabricatorPhurlURLTransaction' => 'applications/phurl/storage/PhabricatorPhurlURLTransaction.php',
|
'PhabricatorPhurlURLTransaction' => 'applications/phurl/storage/PhabricatorPhurlURLTransaction.php',
|
||||||
'PhabricatorPhurlURLTransactionComment' => 'applications/phurl/storage/PhabricatorPhurlURLTransactionComment.php',
|
'PhabricatorPhurlURLTransactionComment' => 'applications/phurl/storage/PhabricatorPhurlURLTransactionComment.php',
|
||||||
|
@ -7069,8 +7071,10 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
|
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
|
||||||
'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController',
|
'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController',
|
||||||
|
'PhabricatorPhurlURLMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||||
'PhabricatorPhurlURLPHIDType' => 'PhabricatorPHIDType',
|
'PhabricatorPhurlURLPHIDType' => 'PhabricatorPHIDType',
|
||||||
'PhabricatorPhurlURLQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorPhurlURLQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'PhabricatorPhurlURLReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||||
'PhabricatorPhurlURLSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhabricatorPhurlURLSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'PhabricatorPhurlURLTransaction' => 'PhabricatorApplicationTransaction',
|
'PhabricatorPhurlURLTransaction' => 'PhabricatorApplicationTransaction',
|
||||||
'PhabricatorPhurlURLTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
'PhabricatorPhurlURLTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||||
|
|
|
@ -194,7 +194,7 @@ final class PhabricatorBadgesEditor
|
||||||
$body = parent::buildMailBody($object, $xactions);
|
$body = parent::buildMailBody($object, $xactions);
|
||||||
|
|
||||||
if (strlen($description)) {
|
if (strlen($description)) {
|
||||||
$body->addRemarkupSeciton(
|
$body->addRemarkupSection(
|
||||||
pht('BADGE DESCRIPTION'),
|
pht('BADGE DESCRIPTION'),
|
||||||
$object->getDescription());
|
$object->getDescription());
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,4 +262,9 @@ final class PhabricatorPhurlURLEditor
|
||||||
throw new PhabricatorApplicationTransactionValidationException($errors);
|
throw new PhabricatorApplicationTransactionValidationException($errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
|
||||||
|
return id(new PhabricatorPhurlURLReplyHandler())
|
||||||
|
->setMailReceiver($object);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPhurlURLMailReceiver
|
||||||
|
extends PhabricatorObjectMailReceiver {
|
||||||
|
|
||||||
|
public function isEnabled() {
|
||||||
|
return PhabricatorApplication::isClassInstalled(
|
||||||
|
'PhabricatorPhurlApplication');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getObjectPattern() {
|
||||||
|
return 'U[1-9]\d*';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadObject($pattern, PhabricatorUser $viewer) {
|
||||||
|
$id = (int)substr($pattern, 1);
|
||||||
|
|
||||||
|
return id(new PhabricatorPhurlURLQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($id))
|
||||||
|
->executeOne();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTransactionReplyHandler() {
|
||||||
|
return new PhabricatorPhurlURLReplyHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPhurlURLReplyHandler
|
||||||
|
extends PhabricatorApplicationTransactionReplyHandler {
|
||||||
|
|
||||||
|
public function validateMailReceiver($mail_receiver) {
|
||||||
|
if (!($mail_receiver instanceof PhabricatorPhurlURL)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Mail receiver is not a %s!',
|
||||||
|
'PhabricatorPhurlURL'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectPrefix() {
|
||||||
|
return 'U';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue