@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 62 lines 1.6 kB view raw
1<?php 2 3final class ManiphestAssignEmailCommand 4 extends ManiphestEmailCommand { 5 6 public function getCommand() { 7 return 'assign'; 8 } 9 10 public function getCommandSyntax() { 11 return '**!assign** //username//'; 12 } 13 14 public function getCommandSummary() { 15 return pht('Assign a task to a specific user.'); 16 } 17 18 public function getCommandDescription() { 19 return pht( 20 "To assign a task to another user, provide their username. For example, ". 21 "to assign a task to `%s`, write `%s`.\n\n". 22 "If you omit the username or the username is not valid, this behaves ". 23 "like `%s` and assigns the task to you instead.", 24 'alincoln', 25 '!assign alincoln', 26 '!claim'); 27 } 28 29 public function buildTransactions( 30 PhabricatorUser $viewer, 31 PhabricatorApplicationTransactionInterface $object, 32 PhabricatorMetaMTAReceivedMail $mail, 33 $command, 34 array $argv) { 35 $xactions = array(); 36 37 $assign_phid = null; 38 39 $assign_to = head($argv); 40 if ($assign_to) { 41 $assign_user = id(new PhabricatorPeopleQuery()) 42 ->setViewer($viewer) 43 ->withUsernames(array($assign_to)) 44 ->executeOne(); 45 if ($assign_user) { 46 $assign_phid = $assign_user->getPHID(); 47 } 48 } 49 50 // Treat bad "!assign" like "!claim". 51 if (!$assign_phid) { 52 $assign_phid = $viewer->getPHID(); 53 } 54 55 $xactions[] = $object->getApplicationTransactionTemplate() 56 ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) 57 ->setNewValue($assign_phid); 58 59 return $xactions; 60 } 61 62}