mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 20:22:46 +01:00
0d99c84bd7
Summary: Ref T7199. This prepares for an exciting new world of more powerful "!action" commands. In particular: - We parse multiple commands per mail. - We parse command arguments (these are currently not used). - We parse commands at the beginning or end of mail. Additionally: - Do a quick modernization pass on all handlers. - Break legacy compatibility with really hacky Facebook stuff (see T1992). They've theoretically been on notice for a year and a half, and their setup relies on calling very old reply handler APIs directly. - Some of these handlers had some copy/paste fluff. - The Releeph handler is unreachable, but fix it //in theory//. Test Plan: - Sent mail to a file; used "!unsubscribe". - Sent mail to a legalpad document; used "!unsubscribe". - Sent mail to a task; used various "!close", "!claim", "!assign", etc. - Sent mail to a paste. - Sent mail to a revision; used various "!reject", "!claim", etc. - Tried to send mail to a pull request but it's not actually reachable. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7199 Differential Revision: https://secure.phabricator.com/D12230
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class ReleephRequestReplyHandler extends PhabricatorMailReplyHandler {
|
|
|
|
public function validateMailReceiver($mail_receiver) {
|
|
if (!($mail_receiver instanceof ReleephRequest)) {
|
|
throw new Exception('Mail receiver is not a ReleephRequest!');
|
|
}
|
|
}
|
|
|
|
public function getPrivateReplyHandlerEmailAddress(
|
|
PhabricatorObjectHandle $handle) {
|
|
return $this->getDefaultPrivateReplyHandlerEmailAddress($handle, 'Y');
|
|
}
|
|
|
|
public function getPublicReplyHandlerEmailAddress() {
|
|
return $this->getDefaultPublicReplyHandlerEmailAddress('Y');
|
|
}
|
|
|
|
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
|
|
$rq = $this->getMailReceiver();
|
|
$user = $this->getActor();
|
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
PhabricatorContentSource::SOURCE_EMAIL,
|
|
array(
|
|
'id' => $mail->getID(),
|
|
));
|
|
|
|
$body = $mail->getCleanTextBody();
|
|
|
|
$xactions = array();
|
|
$xactions[] = id(new ReleephRequestTransaction())
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
->attachComment($body);
|
|
|
|
$editor = id(new ReleephRequestTransactionalEditor())
|
|
->setActor($user)
|
|
->setContentSource($content_source)
|
|
->setContinueOnNoEffect(true)
|
|
->setParentMessageID($mail->getMessageID());
|
|
|
|
$editor->applyTransactions($rq, $xactions);
|
|
}
|
|
|
|
}
|