@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.

When using the Herald test console on a transactional object, guess a reasonable set of transactions to simulate

Summary:
Depends on D20518. Ref T13283. When you use the "Test Console" in Herald to test rules, pass the most recent group of transactions to the Adapter.

This will make it easier to test rules that depend on edit state, since you can make the type of edit you're trying to test and then use the Test Console to actually test if it matches in the way you expect.

The transactions we select may not be exactly the group of transactions that most recently applied. For example, if you make edits A, B, and C in rapid succession and then run the Test Console on the object, it may select "A + B + C" as a transaction group. But we'll show you what we selected and this is basically sane/reasonable and should be fine.

(Eventually, we could include a separate "transaction group ID" on transactions if we want to get this selection to match exactly.)

Test Plan: Ran the Test Console on various objects, saw sensible transaction lists in the transcripts.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13283

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

+39
+39
src/applications/herald/controller/HeraldTestConsoleController.php
··· 46 46 ->setActingAsPHID($viewer->getPHID()) 47 47 ->setViewer($viewer); 48 48 49 + $applied_xactions = $this->loadAppliedTransactions($object); 50 + if ($applied_xactions !== null) { 51 + $adapter->setAppliedTransactions($applied_xactions); 52 + } 53 + 49 54 $rules = id(new HeraldRuleQuery()) 50 55 ->setViewer($viewer) 51 56 ->withContentTypes(array($adapter->getAdapterContentType())) ··· 243 248 244 249 $request = $this->getRequest(); 245 250 return PhabricatorContentSource::newFromRequest($request); 251 + } 252 + 253 + private function loadAppliedTransactions($object) { 254 + $viewer = $this->getViewer(); 255 + 256 + if (!($object instanceof PhabricatorApplicationTransactionInterface)) { 257 + return null; 258 + } 259 + 260 + $query = PhabricatorApplicationTransactionQuery::newQueryForObject( 261 + $object); 262 + 263 + $xactions = $query 264 + ->withObjectPHIDs(array($object->getPHID())) 265 + ->setViewer($viewer) 266 + ->setLimit(100) 267 + ->execute(); 268 + 269 + $applied = array(); 270 + 271 + // Pick the most recent group of transactions. This may not be exactly the 272 + // same as what Herald acted on: for example, we may select a single group 273 + // of transactions here which were really applied across two or more edits. 274 + // Since this is relatively rare and we show you what we picked, it's okay 275 + // that we just do roughly the right thing. 276 + foreach ($xactions as $xaction) { 277 + if (!$xaction->shouldDisplayGroupWith($applied)) { 278 + break; 279 + } 280 + $applied[] = $xaction; 281 + } 282 + 283 + return $applied; 284 + 246 285 } 247 286 248 287 }