@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<?php
2
3final class DifferentialChangesSinceLastUpdateField
4 extends DifferentialCustomField {
5
6 public function getFieldKey() {
7 return 'differential:changes-since-last-update';
8 }
9
10 public function getFieldName() {
11 return pht('Changes Since Last Update');
12 }
13
14 public function getFieldDescription() {
15 return pht('Links to changes since the last update in email.');
16 }
17
18 public function shouldAppearInTransactionMail() {
19 return true;
20 }
21
22 public function updateTransactionMailBody(
23 PhabricatorMetaMTAMailBody $body,
24 PhabricatorApplicationTransactionEditor $editor,
25 array $xactions) {
26
27 if ($editor->isFirstBroadcast()) {
28 return;
29 }
30
31 if ($editor->getIsCloseByCommit()) {
32 return;
33 }
34
35 $xaction = $editor->getDiffUpdateTransaction($xactions);
36 if (!$xaction) {
37 return;
38 }
39
40 $original = id(new DifferentialDiffQuery())
41 ->setViewer($this->getViewer())
42 ->withPHIDs(array($xaction->getOldValue()))
43 ->executeOne();
44 if (!$original) {
45 return;
46 }
47
48 $revision = $this->getObject();
49 $current = $revision->getActiveDiff();
50
51 $old_id = $original->getID();
52 $new_id = $current->getID();
53
54 $uri = '/'.$revision->getMonogram().'?vs='.$old_id.'&id='.$new_id;
55 $uri = PhabricatorEnv::getProductionURI($uri);
56
57 $body->addLinkSection(pht('CHANGES SINCE LAST UPDATE'), $uri);
58 }
59
60}