1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Run Maniphest Conduit writes through new editor

Summary: Ref T2217. Swap the editors for the Conduit writes.

Test Plan: Made a bazillion Conduit calls, saw tasks updated appropriately.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

Differential Revision: https://secure.phabricator.com/D7082
This commit is contained in:
epriestley 2013-09-23 14:32:08 -07:00
parent efc7e7cd7e
commit 2bc46f097e
3 changed files with 62 additions and 13 deletions

View file

@ -138,28 +138,27 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
$changes[ManiphestTransactionType::TYPE_ATTACH] = $attached; $changes[ManiphestTransactionType::TYPE_ATTACH] = $attached;
} }
$content_source = PhabricatorContentSource::newForSource( $template = new ManiphestTransactionPro();
PhabricatorContentSource::SOURCE_CONDUIT,
array());
$template = new ManiphestTransaction();
$template->setContentSource($content_source);
$template->setAuthorPHID($request->getUser()->getPHID());
$transactions = array(); $transactions = array();
foreach ($changes as $type => $value) { foreach ($changes as $type => $value) {
$transaction = clone $template; $transaction = clone $template;
$transaction->setTransactionType($type); $transaction->setTransactionType($type);
$transaction->setNewValue($value);
if ($type == PhabricatorTransactions::TYPE_COMMENT) { if ($type == PhabricatorTransactions::TYPE_COMMENT) {
$transaction->setComments($comments); $transaction->attachComment(
id(new ManiphestTransactionComment())
->setContent($comments));
} else {
$transaction->setNewValue($value);
} }
$transactions[] = $transaction; $transactions[] = $transaction;
} }
$field_list = PhabricatorCustomField::getObjectFields( $field_list = PhabricatorCustomField::getObjectFields(
$task, $task,
PhabricatorCustomField::ROLE_EDIT); PhabricatorCustomField::ROLE_EDIT);
$field_list->readFieldsFromStorage($task);
$auxiliary = $request->getValue('auxiliary'); $auxiliary = $request->getValue('auxiliary');
if ($auxiliary) { if ($auxiliary) {
@ -196,9 +195,15 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
$task = $event->getValue('task'); $task = $event->getValue('task');
$transactions = $event->getValue('transactions'); $transactions = $event->getValue('transactions');
$editor = new ManiphestTransactionEditor(); $content_source = PhabricatorContentSource::newForSource(
$editor->setActor($request->getUser()); PhabricatorContentSource::SOURCE_CONDUIT,
$editor->setAuxiliaryFields($field_list->getFields()); array());
$editor = id(new ManiphestTransactionEditorPro())
->setActor($request->getUser())
->setContentSource($content_source)
->setContinueOnNoEffect(true);
$editor->applyTransactions($task, $transactions); $editor->applyTransactions($task, $transactions);
$event = new PhabricatorEvent( $event = new PhabricatorEvent(

View file

@ -8,6 +8,13 @@ final class ManiphestTransactionEditorPro
$types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = ManiphestTransactionPro::TYPE_PRIORITY; $types[] = ManiphestTransactionPro::TYPE_PRIORITY;
$types[] = ManiphestTransactionPro::TYPE_STATUS;
$types[] = ManiphestTransactionPro::TYPE_TITLE;
$types[] = ManiphestTransactionPro::TYPE_DESCRIPTION;
$types[] = ManiphestTransactionPro::TYPE_OWNER;
$types[] = ManiphestTransactionPro::TYPE_CCS;
$types[] = ManiphestTransactionPro::TYPE_PROJECTS;
$types[] = ManiphestTransactionPro::TYPE_ATTACH;
return $types; return $types;
} }
@ -18,7 +25,21 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY: case ManiphestTransactionPro::TYPE_PRIORITY:
return $object->getPriority(); return (int)$object->getPriority();
case ManiphestTransactionPro::TYPE_STATUS:
return (int)$object->getStatus();
case ManiphestTransactionPro::TYPE_TITLE:
return $object->getTitle();
case ManiphestTransactionPro::TYPE_DESCRIPTION:
return $object->getDescription();
case ManiphestTransactionPro::TYPE_OWNER:
return $object->getOwnerPHID();
case ManiphestTransactionPro::TYPE_CCS:
return $object->getCCPHIDs();
case ManiphestTransactionPro::TYPE_PROJECTS:
return $object->getProjectPHIDs();
case ManiphestTransactionPro::TYPE_ATTACH:
return $object->getAttached();
} }
} }
@ -29,6 +50,14 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY: case ManiphestTransactionPro::TYPE_PRIORITY:
case ManiphestTransactionPro::TYPE_STATUS:
return (int)$xaction->getNewValue();
case ManiphestTransactionPro::TYPE_TITLE:
case ManiphestTransactionPro::TYPE_DESCRIPTION:
case ManiphestTransactionPro::TYPE_OWNER:
case ManiphestTransactionPro::TYPE_CCS:
case ManiphestTransactionPro::TYPE_PROJECTS:
case ManiphestTransactionPro::TYPE_ATTACH:
return $xaction->getNewValue(); return $xaction->getNewValue();
} }
@ -41,6 +70,20 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY: case ManiphestTransactionPro::TYPE_PRIORITY:
return $object->setPriority($xaction->getNewValue()); return $object->setPriority($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_STATUS:
return $object->setStatus($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_TITLE:
return $object->setTitle($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_DESCRIPTION:
return $object->setDescription($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_OWNER:
return $object->setOwnerPHID($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_CCS:
return $object->setCCPHIDs($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_PROJECTS:
return $object->setProjectPHIDs($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_ATTACH:
return $object->setAttached($xaction->getNewValue());
} }
} }

View file

@ -272,6 +272,7 @@ abstract class PhabricatorStandardCustomField
if ($this->getRequired()) { if ($this->getRequired()) {
$value = $this->getOldValueForApplicationTransactions(); $value = $this->getOldValueForApplicationTransactions();
$transaction = null; $transaction = null;
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
$value = $xaction->getNewValue(); $value = $xaction->getNewValue();