Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
index bbb5278bbf..9842d08b90 100644
--- a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
@@ -1,123 +1,116 @@
<?php
final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
private $commit;
private $attachInlineComments;
- private $noEmail;
public function __construct(PhabricatorRepositoryCommit $commit) {
$this->commit = $commit;
return $this;
}
public function setAttachInlineComments($attach_inline_comments) {
$this->attachInlineComments = $attach_inline_comments;
return $this;
}
- public function setNoEmail($no_email) {
- $this->noEmail = $no_email;
- return $this;
- }
-
public function addComments(array $comments) {
assert_instances_of($comments, 'PhabricatorAuditComment');
$commit = $this->commit;
$actor = $this->getActor();
$other_comments = PhabricatorAuditComment::loadComments(
$actor,
$commit->getPHID());
$inline_comments = array();
if ($this->attachInlineComments) {
$inline_comments = PhabricatorAuditInlineComment::loadDraftComments(
$actor,
$commit->getPHID());
}
// Convert old comments into real transactions and apply them with a
// normal editor.
$xactions = array();
foreach ($comments as $comment) {
$xactions[] = $comment->getTransactionForSave();
}
foreach ($inline_comments as $inline) {
$xactions[] = id(new PhabricatorAuditTransaction())
->setTransactionType(PhabricatorAuditActionConstants::INLINE)
->attachComment($inline->getTransactionComment());
}
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array());
$editor = id(new PhabricatorAuditEditor())
->setActor($actor)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->setContentSource($content_source)
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
- ->setDisableEmail($this->noEmail)
->applyTransactions($commit, $xactions);
}
/**
* Load the PHIDs for all objects the user has the authority to act as an
* audit for. This includes themselves, and any packages they are an owner
* of.
*/
public static function loadAuditPHIDsForUser(PhabricatorUser $user) {
$phids = array();
// TODO: This method doesn't really use the right viewer, but in practice we
// never issue this query of this type on behalf of another user and are
// unlikely to do so in the future. This entire method should be refactored
// into a Query class, however, and then we should use a proper viewer.
// The user can audit on their own behalf.
$phids[$user->getPHID()] = true;
$owned_packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($user)
->withOwnerPHIDs(array($user->getPHID()))
->execute();
foreach ($owned_packages as $package) {
$phids[$package->getPHID()] = true;
}
// The user can audit on behalf of all projects they are a member of.
$projects = id(new PhabricatorProjectQuery())
->setViewer($user)
->withMemberPHIDs(array($user->getPHID()))
->execute();
foreach ($projects as $project) {
$phids[$project->getPHID()] = true;
}
return array_keys($phids);
}
public static function newReplyHandlerForCommit($commit) {
$reply_handler = PhabricatorEnv::newObjectFromConfig(
'metamta.diffusion.reply-handler');
$reply_handler->setMailReceiver($commit);
return $reply_handler;
}
public static function getMailThreading(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
return array(
'diffusion-audit-'.$commit->getPHID(),
'Commit r'.$repository->getCallsign().$commit->getCommitIdentifier(),
);
}
}
diff --git a/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php
index 9ed0ebe235..e0e3927f93 100644
--- a/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionCreateCommentConduitAPIMethod.php
@@ -1,96 +1,100 @@
<?php
final class DiffusionCreateCommentConduitAPIMethod
extends DiffusionConduitAPIMethod {
public function getAPIMethodName() {
return 'diffusion.createcomment';
}
public function getMethodStatus() {
return self::METHOD_STATUS_DEPRECATED;
}
public function getMethodDescription() {
return 'Add a comment to a Diffusion commit. By specifying an action of '.
'"concern", "accept", "resign", or "close", auditing actions can '.
'be triggered. Defaults to "comment".';
}
public function defineParamTypes() {
return array(
'phid' => 'required string',
'action' => 'optional string',
'message' => 'required string',
'silent' => 'optional bool',
);
}
public function defineReturnType() {
return 'bool';
}
public function defineErrorTypes() {
return array(
'ERR_BAD_COMMIT' => 'No commit found with that PHID',
'ERR_BAD_ACTION' => 'Invalid action type',
'ERR_MISSING_MESSAGE' => 'Message is required',
);
}
protected function execute(ConduitAPIRequest $request) {
$commit_phid = $request->getValue('phid');
$commit = id(new DiffusionCommitQuery())
->setViewer($request->getUser())
->withPHIDs(array($commit_phid))
->needAuditRequests(true)
->executeOne();
if (!$commit) {
throw new ConduitException('ERR_BAD_COMMIT');
}
$message = trim($request->getValue('message'));
if (!$message) {
throw new ConduitException('ERR_MISSING_MESSAGE');
}
$action = $request->getValue('action');
if (!$action) {
$action = PhabricatorAuditActionConstants::COMMENT;
}
- // Disallow ADD_CCS, ADD_AUDITORS for now
+ // Disallow ADD_CCS, ADD_AUDITORS forever.
if (!in_array($action, array(
PhabricatorAuditActionConstants::CONCERN,
PhabricatorAuditActionConstants::ACCEPT,
PhabricatorAuditActionConstants::COMMENT,
PhabricatorAuditActionConstants::RESIGN,
PhabricatorAuditActionConstants::CLOSE,
))) {
throw new ConduitException('ERR_BAD_ACTION');
}
- $comments = array();
+ $xactions = array();
if ($action != PhabricatorAuditActionConstants::COMMENT) {
- $comments[] = id(new PhabricatorAuditComment())
- ->setAction($action);
+ $xactions[] = id(new PhabricatorAuditTransaction())
+ ->setTransactionType(PhabricatorAuditActionConstants::ACTION)
+ ->setNewValue($action);
}
if (strlen($message)) {
- $comments[] = id(new PhabricatorAuditComment())
- ->setAction(PhabricatorAuditActionConstants::COMMENT)
- ->setContent($message);
+ $xactions[] = id(new PhabricatorAuditTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
+ ->attachComment(
+ id(new PhabricatorAuditTransactionComment())
+ ->setCommitPHID($commit->getPHID())
+ ->setContent($message));
}
- id(new PhabricatorAuditCommentEditor($commit))
+ id(new PhabricatorAuditEditor())
->setActor($request->getUser())
- ->setNoEmail($request->getValue('silent'))
- ->addComments($comments);
+ ->setContentSourceFromConduitRequest($request)
+ ->setDisableEmail($request->getValue('silent'))
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($commit, $xactions);
return true;
- // get the full uri of the comment?
- // i.e, PhabricatorEnv::getURI(rXX01ab23cd#comment-9)
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 12:37 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1124645
Default Alt Text
(7 KB)

Event Timeline