mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-23 13:08:18 +01:00
Add a Nuance content source, and make use of it
Summary: Ref T10537. Add a new content source for Nuance. Prepare for better author attribution. Test Plan: {F1194038} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10537 Differential Revision: https://secure.phabricator.com/D15539
This commit is contained in:
parent
878b941309
commit
f9306c2e58
4 changed files with 43 additions and 9 deletions
|
@ -1426,6 +1426,7 @@ phutil_register_library_map(array(
|
||||||
'MultimeterViewer' => 'applications/multimeter/storage/MultimeterViewer.php',
|
'MultimeterViewer' => 'applications/multimeter/storage/MultimeterViewer.php',
|
||||||
'NuanceConduitAPIMethod' => 'applications/nuance/conduit/NuanceConduitAPIMethod.php',
|
'NuanceConduitAPIMethod' => 'applications/nuance/conduit/NuanceConduitAPIMethod.php',
|
||||||
'NuanceConsoleController' => 'applications/nuance/controller/NuanceConsoleController.php',
|
'NuanceConsoleController' => 'applications/nuance/controller/NuanceConsoleController.php',
|
||||||
|
'NuanceContentSource' => 'applications/nuance/contentsource/NuanceContentSource.php',
|
||||||
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
||||||
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
||||||
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
||||||
|
@ -5726,6 +5727,7 @@ phutil_register_library_map(array(
|
||||||
'MultimeterViewer' => 'MultimeterDimension',
|
'MultimeterViewer' => 'MultimeterDimension',
|
||||||
'NuanceConduitAPIMethod' => 'ConduitAPIMethod',
|
'NuanceConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'NuanceConsoleController' => 'NuanceController',
|
'NuanceConsoleController' => 'NuanceController',
|
||||||
|
'NuanceContentSource' => 'PhabricatorContentSource',
|
||||||
'NuanceController' => 'PhabricatorController',
|
'NuanceController' => 'PhabricatorController',
|
||||||
'NuanceDAO' => 'PhabricatorLiskDAO',
|
'NuanceDAO' => 'PhabricatorLiskDAO',
|
||||||
'NuanceGitHubEventItemType' => 'NuanceItemType',
|
'NuanceGitHubEventItemType' => 'NuanceItemType',
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class NuanceContentSource
|
||||||
|
extends PhabricatorContentSource {
|
||||||
|
|
||||||
|
const SOURCECONST = 'nuance';
|
||||||
|
|
||||||
|
public function getSourceName() {
|
||||||
|
return pht('Nuance');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSourceDescription() {
|
||||||
|
return pht('Content imported via Nuance.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -297,7 +297,7 @@ final class NuanceGitHubEventItemType
|
||||||
$xobj_phid));
|
$xobj_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
$nuance_phid = id(new PhabricatorNuanceApplication())->getPHID();
|
$acting_as_phid = $this->getActingAsPHID($item);
|
||||||
|
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ final class NuanceGitHubEventItemType
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$task) {
|
if (!$task) {
|
||||||
$task = ManiphestTask::initializeNewTask($viewer)
|
$task = ManiphestTask::initializeNewTask($viewer)
|
||||||
->setAuthorPHID($nuance_phid)
|
->setAuthorPHID($acting_as_phid)
|
||||||
->setBridgedObjectPHID($xobj_phid);
|
->setBridgedObjectPHID($xobj_phid);
|
||||||
|
|
||||||
$title = $xobj->getProperty('task.title');
|
$title = $xobj->getProperty('task.title');
|
||||||
|
@ -344,16 +344,12 @@ final class NuanceGitHubEventItemType
|
||||||
->setContent($comment));
|
->setContent($comment));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Preserve the item's original source.
|
$agent_phid = $command->getAuthorPHID();
|
||||||
$source = PhabricatorContentSource::newForSource(
|
$source = $this->newContentSource($item, $agent_phid);
|
||||||
PhabricatorDaemonContentSource::SOURCECONST);
|
|
||||||
|
|
||||||
// TODO: This should really be the external source.
|
|
||||||
$acting_phid = $nuance_phid;
|
|
||||||
|
|
||||||
$editor = id(new ManiphestTransactionEditor())
|
$editor = id(new ManiphestTransactionEditor())
|
||||||
->setActor($viewer)
|
->setActor($viewer)
|
||||||
->setActingAsPHID($acting_phid)
|
->setActingAsPHID($acting_as_phid)
|
||||||
->setContentSource($source)
|
->setContentSource($source)
|
||||||
->setContinueOnNoEffect(true)
|
->setContinueOnNoEffect(true)
|
||||||
->setContinueOnMissingFields(true);
|
->setContinueOnMissingFields(true);
|
||||||
|
@ -366,5 +362,10 @@ final class NuanceGitHubEventItemType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getActingAsPHID(NuanceItem $item) {
|
||||||
|
// TODO: This should be an external account PHID representing the original
|
||||||
|
// GitHub user.
|
||||||
|
return parent::getActingAsPHID($item);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,4 +144,19 @@ abstract class NuanceItemType
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final protected function newContentSource(
|
||||||
|
NuanceItem $item,
|
||||||
|
$agent_phid) {
|
||||||
|
return PhabricatorContentSource::newForSource(
|
||||||
|
NuanceContentSource::SOURCECONST,
|
||||||
|
array(
|
||||||
|
'itemPHID' => $item->getPHID(),
|
||||||
|
'agentPHID' => $agent_phid,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getActingAsPHID(NuanceItem $item) {
|
||||||
|
return id(new PhabricatorNuanceApplication())->getPHID();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue