@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow ModularTransactions to opt in to providing data to Conduit

Summary:
Ref T5873. See PHI14. I don't want to just expose internal transaction data to Conduit by default, since it's often: unstable, unusable, sensitive, or some combination of the three.

Instead, let ModularTransactions opt in to providing additional data to Conduit, similar to other infrastructure. If a transaction doesn't, the API returns an empty skeleton for it. This is generally fine since most transactions have no real use cases, and I think we can fill them in as we go.

This also probably builds toward T5726, which would likely use the same format, and perhaps simply not publish stuff which did not opt in.

This doesn't actually cover "comment" or "inline comment", which are presumably what PHI14 is after, since neither is modular. I'll probably just put a hack in place for this until they can modularize since I suspect modularizing them here is difficult.

Test Plan: Ran `transaction.search` on a revision, saw some transactions (title and status transactions) populate with values.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5873

Differential Revision: https://secure.phabricator.com/D18467

+77
+11
src/applications/differential/xaction/DifferentialRevisionStatusTransaction.php
··· 70 70 return DifferentialRevisionStatus::newForStatus($new); 71 71 } 72 72 73 + public function getTransactionTypeForConduit($xaction) { 74 + return 'status'; 75 + } 76 + 77 + public function getFieldValuesForConduit($object, $data) { 78 + return array( 79 + 'old' => $object->getOldValue(), 80 + 'new' => $object->getNewValue(), 81 + ); 82 + } 83 + 73 84 }
+11
src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
··· 55 55 return $errors; 56 56 } 57 57 58 + public function getTransactionTypeForConduit($xaction) { 59 + return 'title'; 60 + } 61 + 62 + public function getFieldValuesForConduit($object, $data) { 63 + return array( 64 + 'old' => $object->getOldValue(), 65 + 'new' => $object->getNewValue(), 66 + ); 67 + } 68 + 58 69 }
+43
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
··· 89 89 $comment_map = array(); 90 90 } 91 91 92 + $modular_classes = array(); 93 + $modular_objects = array(); 94 + $modular_xactions = array(); 95 + foreach ($xactions as $xaction) { 96 + if (!$xaction instanceof PhabricatorModularTransaction) { 97 + continue; 98 + } 99 + 100 + $modular_template = $xaction->getModularType(); 101 + $modular_class = get_class($modular_template); 102 + if (!isset($modular_objects[$modular_class])) { 103 + try { 104 + $modular_object = newv($modular_class, array()); 105 + $modular_objects[$modular_class] = $modular_object; 106 + } catch (Exception $ex) { 107 + continue; 108 + } 109 + } 110 + 111 + $modular_classes[$xaction->getPHID()] = $modular_class; 112 + $modular_xactions[$modular_class][] = $xaction; 113 + } 114 + 115 + $modular_data_map = array(); 116 + foreach ($modular_objects as $class => $modular_type) { 117 + $modular_data_map[$class] = $modular_type 118 + ->setViewer($viewer) 119 + ->loadTransactionTypeConduitData($modular_xactions[$class]); 120 + } 121 + 92 122 $data = array(); 93 123 foreach ($xactions as $xaction) { 94 124 $comments = idx($comment_map, $xaction->getPHID()); ··· 126 156 } 127 157 128 158 $fields = array(); 159 + $type = null; 160 + 161 + if (isset($modular_classes[$xaction->getPHID()])) { 162 + $modular_class = $modular_classes[$xaction->getPHID()]; 163 + $modular_object = $modular_objects[$modular_class]; 164 + $modular_data = $modular_data_map[$modular_class]; 165 + 166 + $type = $modular_object->getTransactionTypeForConduit($xaction); 167 + $fields = $modular_object->getFieldValuesForConduit( 168 + $xaction, 169 + $modular_data); 170 + } 129 171 130 172 if (!$fields) { 131 173 $fields = (object)$fields; ··· 134 176 $data[] = array( 135 177 'id' => (int)$xaction->getID(), 136 178 'phid' => (string)$xaction->getPHID(), 179 + 'type' => $type, 137 180 'authorPHID' => (string)$xaction->getAuthorPHID(), 138 181 'objectPHID' => (string)$xaction->getObjectPHID(), 139 182 'dateCreated' => (int)$xaction->getDateCreated(),
+12
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 332 332 return $this->getStorage()->getMetadataValue($key, $default); 333 333 } 334 334 335 + public function loadTransactionTypeConduitData(array $xactions) { 336 + return null; 337 + } 338 + 339 + public function getTransactionTypeForConduit($xaction) { 340 + return null; 341 + } 342 + 343 + public function getFieldValuesForConduit($xaction, $data) { 344 + return array(); 345 + } 346 + 335 347 }