mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Implement a "!projects" mail command
Summary: Ref T7199. Implements `!projects` for all objects which implement `PhabricatorProjectInterface`. Test Plan: Added projects to a task via email. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7199 Differential Revision: https://secure.phabricator.com/D12246
This commit is contained in:
parent
25f8a37f85
commit
cb6349b88c
2 changed files with 72 additions and 0 deletions
|
@ -3025,6 +3025,7 @@ phutil_register_library_map(array(
|
||||||
'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php',
|
'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php',
|
||||||
'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php',
|
'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php',
|
||||||
'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php',
|
'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php',
|
||||||
|
'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php',
|
||||||
'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php',
|
'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php',
|
||||||
'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php',
|
'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php',
|
||||||
'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php',
|
'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php',
|
||||||
|
@ -6517,6 +6518,7 @@ phutil_register_library_map(array(
|
||||||
'PonderVoteSaveController' => 'PonderController',
|
'PonderVoteSaveController' => 'PonderController',
|
||||||
'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType',
|
'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType',
|
'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType',
|
||||||
|
'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand',
|
||||||
'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability',
|
'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability',
|
||||||
'ProjectConduitAPIMethod' => 'ConduitAPIMethod',
|
'ProjectConduitAPIMethod' => 'ConduitAPIMethod',
|
||||||
'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod',
|
'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod',
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class ProjectAddProjectsEmailCommand
|
||||||
|
extends MetaMTAEmailTransactionCommand {
|
||||||
|
|
||||||
|
public function getCommand() {
|
||||||
|
return 'projects';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommandSyntax() {
|
||||||
|
return '**!projects** //#project ...//';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommandSummary() {
|
||||||
|
return pht('Add related projects.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommandDescription() {
|
||||||
|
return pht(
|
||||||
|
'Add one or more projects to the object by listing their hashtags. '.
|
||||||
|
'Separate projects with spaces. For example, use `!projects #ios '.
|
||||||
|
'#feature` to add both related projects.'.
|
||||||
|
"\n\n".
|
||||||
|
'Projects which are invalid or unrecognized will be ignored. This '.
|
||||||
|
'command has no effect if you do not specify any projects.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommandAliases() {
|
||||||
|
return array(
|
||||||
|
'project',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isCommandSupportedForObject(
|
||||||
|
PhabricatorApplicationTransactionInterface $object) {
|
||||||
|
return ($object instanceof PhabricatorProjectInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildTransactions(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
PhabricatorApplicationTransactionInterface $object,
|
||||||
|
PhabricatorMetaMTAReceivedMail $mail,
|
||||||
|
$command,
|
||||||
|
array $argv) {
|
||||||
|
|
||||||
|
$project_phids = id(new PhabricatorObjectListQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->setAllowedTypes(
|
||||||
|
array(
|
||||||
|
PhabricatorProjectProjectPHIDType::TYPECONST,
|
||||||
|
))
|
||||||
|
->setObjectList(implode(' ', $argv))
|
||||||
|
->setAllowPartialResults(true)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$xactions = array();
|
||||||
|
|
||||||
|
$type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
|
$xactions[] = $object->getApplicationTransactionTemplate()
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
|
->setMetadataValue('edge:type', $type_project)
|
||||||
|
->setNewValue(
|
||||||
|
array(
|
||||||
|
'+' => array_fuse($project_phids),
|
||||||
|
));
|
||||||
|
|
||||||
|
return $xactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue