diff --git a/src/applications/paste/editor/PhabricatorPasteEditor.php b/src/applications/paste/editor/PhabricatorPasteEditor.php --- a/src/applications/paste/editor/PhabricatorPasteEditor.php +++ b/src/applications/paste/editor/PhabricatorPasteEditor.php @@ -3,6 +3,12 @@ final class PhabricatorPasteEditor extends PhabricatorApplicationTransactionEditor { + private $newPasteTitle; + + public function getNewPasteTitle() { + return $this->newPasteTitle; + } + public function getEditorApplicationClass() { return 'PhabricatorPasteApplication'; } @@ -29,6 +35,22 @@ return $types; } + protected function expandTransactions( + PhabricatorLiskDAO $object, + array $xactions) { + + $new_title = $object->getTitle(); + foreach ($xactions as $xaction) { + $type = $xaction->getTransactionType(); + if ($type === PhabricatorPasteTitleTransaction::TRANSACTIONTYPE) { + $new_title = $xaction->getNewValue(); + } + } + $this->newPasteTitle = $new_title; + + return parent::expandTransactions($object, $xactions); + } + protected function shouldSendMail( PhabricatorLiskDAO $object, array $xactions) { diff --git a/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php b/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php --- a/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php +++ b/src/applications/paste/xaction/PhabricatorPasteContentTransaction.php @@ -50,10 +50,17 @@ } private function newFileForPaste(PhabricatorUser $actor, $data) { + $editor = $this->getEditor(); + + $file_name = $editor->getNewPasteTitle(); + if (!strlen($file_name)) { + $file_name = 'raw-paste-data.txt'; + } + return PhabricatorFile::newFromFileData( $data, array( - 'name' => 'raw.txt', + 'name' => $file_name, 'mime-type' => 'text/plain; charset=utf-8', 'authorPHID' => $actor->getPHID(), 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,