mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +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',
|
||||
'NuanceConduitAPIMethod' => 'applications/nuance/conduit/NuanceConduitAPIMethod.php',
|
||||
'NuanceConsoleController' => 'applications/nuance/controller/NuanceConsoleController.php',
|
||||
'NuanceContentSource' => 'applications/nuance/contentsource/NuanceContentSource.php',
|
||||
'NuanceController' => 'applications/nuance/controller/NuanceController.php',
|
||||
'NuanceDAO' => 'applications/nuance/storage/NuanceDAO.php',
|
||||
'NuanceGitHubEventItemType' => 'applications/nuance/item/NuanceGitHubEventItemType.php',
|
||||
|
@ -5726,6 +5727,7 @@ phutil_register_library_map(array(
|
|||
'MultimeterViewer' => 'MultimeterDimension',
|
||||
'NuanceConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'NuanceConsoleController' => 'NuanceController',
|
||||
'NuanceContentSource' => 'PhabricatorContentSource',
|
||||
'NuanceController' => 'PhabricatorController',
|
||||
'NuanceDAO' => 'PhabricatorLiskDAO',
|
||||
'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));
|
||||
}
|
||||
|
||||
$nuance_phid = id(new PhabricatorNuanceApplication())->getPHID();
|
||||
$acting_as_phid = $this->getActingAsPHID($item);
|
||||
|
||||
$xactions = array();
|
||||
|
||||
|
@ -307,7 +307,7 @@ final class NuanceGitHubEventItemType
|
|||
->executeOne();
|
||||
if (!$task) {
|
||||
$task = ManiphestTask::initializeNewTask($viewer)
|
||||
->setAuthorPHID($nuance_phid)
|
||||
->setAuthorPHID($acting_as_phid)
|
||||
->setBridgedObjectPHID($xobj_phid);
|
||||
|
||||
$title = $xobj->getProperty('task.title');
|
||||
|
@ -344,16 +344,12 @@ final class NuanceGitHubEventItemType
|
|||
->setContent($comment));
|
||||
}
|
||||
|
||||
// TODO: Preserve the item's original source.
|
||||
$source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorDaemonContentSource::SOURCECONST);
|
||||
|
||||
// TODO: This should really be the external source.
|
||||
$acting_phid = $nuance_phid;
|
||||
$agent_phid = $command->getAuthorPHID();
|
||||
$source = $this->newContentSource($item, $agent_phid);
|
||||
|
||||
$editor = id(new ManiphestTransactionEditor())
|
||||
->setActor($viewer)
|
||||
->setActingAsPHID($acting_phid)
|
||||
->setActingAsPHID($acting_as_phid)
|
||||
->setContentSource($source)
|
||||
->setContinueOnNoEffect(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;
|
||||
}
|
||||
|
||||
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…
Reference in a new issue