Page MenuHomePhabricator

D11574.id27852.diff
No OneTemporary

D11574.id27852.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -322,6 +322,7 @@
'DifferentialCreateCommentConduitAPIMethod' => 'applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php',
'DifferentialCreateDiffConduitAPIMethod' => 'applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php',
'DifferentialCreateInlineConduitAPIMethod' => 'applications/differential/conduit/DifferentialCreateInlineConduitAPIMethod.php',
+ 'DifferentialCreateMailReceiver' => 'applications/differential/mail/DifferentialCreateMailReceiver.php',
'DifferentialCreateRawDiffConduitAPIMethod' => 'applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php',
'DifferentialCreateRevisionConduitAPIMethod' => 'applications/differential/conduit/DifferentialCreateRevisionConduitAPIMethod.php',
'DifferentialCustomField' => 'applications/differential/customfield/DifferentialCustomField.php',
@@ -3421,6 +3422,7 @@
'DifferentialCreateCommentConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateDiffConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateInlineConduitAPIMethod' => 'DifferentialConduitAPIMethod',
+ 'DifferentialCreateMailReceiver' => 'PhabricatorMailReceiver',
'DifferentialCreateRawDiffConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCreateRevisionConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCustomField' => 'PhabricatorCustomField',
diff --git a/src/applications/differential/application/PhabricatorDifferentialApplication.php b/src/applications/differential/application/PhabricatorDifferentialApplication.php
--- a/src/applications/differential/application/PhabricatorDifferentialApplication.php
+++ b/src/applications/differential/application/PhabricatorDifferentialApplication.php
@@ -162,6 +162,21 @@
return $status;
}
+ public function supportsEmailIntegration() {
+ return true;
+ }
+
+ public function getAppEmailBlurb() {
+ return pht(
+ 'Send email to these addresses to create revisions. The body of the '.
+ 'message should the output of a `diff` command. %s',
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => $this->getInboundEmailSupportLink(),),
+ pht('Learn More')));
+ }
+
protected function getCustomCapabilities() {
return array(
DifferentialDefaultViewCapability::CAPABILITY => array(
diff --git a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
--- a/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialConduitAPIMethod.php
@@ -12,8 +12,9 @@
$uri = PhabricatorEnv::getProductionURI($uri);
return array(
- 'id' => $diff->getID(),
- 'uri' => $uri,
+ 'id' => $diff->getID(),
+ 'phid' => $diff->getPHID(),
+ 'uri' => $uri,
);
}
diff --git a/src/applications/differential/mail/DifferentialCreateMailReceiver.php b/src/applications/differential/mail/DifferentialCreateMailReceiver.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/mail/DifferentialCreateMailReceiver.php
@@ -0,0 +1,73 @@
+<?php
+
+final class DifferentialCreateMailReceiver extends PhabricatorMailReceiver {
+
+ public function isEnabled() {
+ $app_class = 'PhabricatorDifferentialApplication';
+ return PhabricatorApplication::isClassInstalled($app_class);
+ }
+
+ public function canAcceptMail(PhabricatorMetaMTAReceivedMail $mail) {
+ $differential_app = new PhabricatorDifferentialApplication();
+ return $this->canAcceptApplicationMail($differential_app, $mail);
+ }
+
+ protected function processReceivedMail(
+ PhabricatorMetaMTAReceivedMail $mail,
+ PhabricatorUser $sender) {
+
+ $title = $mail->getSubject();
+ if (!$title) {
+ $title = pht('Email Revision');
+ }
+
+ $call = new ConduitCall(
+ 'differential.createrawdiff',
+ array(
+ 'diff' => $mail->getCleanTextBody(),));
+ $call->setUser($sender);
+ $result = $call->execute();
+ $diff_phid = $result['phid'];
+ $revision = DifferentialRevision::initializeNewRevision($sender)
+ ->attachReviewerStatus(array())
+ ->setTitle($title);
+
+ $xactions = array();
+ $xactions[] = id(new DifferentialTransaction())
+ ->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
+ ->setNewValue($diff_phid);
+
+ $content_source = PhabricatorContentSource::newForSource(
+ PhabricatorContentSource::SOURCE_EMAIL,
+ array(
+ 'id' => $mail->getID(),
+ ));
+
+ $editor = id(new DifferentialTransactionEditor())
+ ->setActor($sender)
+ ->setContentSource($content_source)
+ ->setContinueOnNoEffect(true);
+ $xactions = $editor->applyTransactions($revision, $xactions);
+
+ $mail->setRelatedPHID($revision->getPHID());
+
+ $subject_prefix =
+ PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix');
+ $subject = pht('You successfully created a revision.');
+ $revision_uri = PhabricatorEnv::getProductionURI(
+ $revision->getMonogram());
+ $body = new PhabricatorMetaMTAMailBody();
+ $body->addRawSection($subject);
+ $body->addTextSection(pht('REVISION LINK'), $revision_uri);
+
+ id(new PhabricatorMetaMTAMail())
+ ->addTos(array($sender->getPHID()))
+ ->setSubject($subject)
+ ->setSubjectPrefix($subject_prefix)
+ ->setFrom($sender->getPHID())
+ ->setRelatedPHID($revision->getPHID())
+ ->setBody($body->render())
+ ->saveAndSend();
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 25, 11:11 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6749376
Default Alt Text
D11574.id27852.diff (5 KB)

Event Timeline