@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 PhabricatorEditorMailEngineExtension
4 extends PhabricatorMailEngineExtension {
5
6 const EXTENSIONKEY = 'editor';
7
8 public function supportsObject($object) {
9 return true;
10 }
11
12 public function newMailStampTemplates($object) {
13 $templates = array();
14
15 $templates[] = id(new PhabricatorPHIDMailStamp())
16 ->setKey('actor')
17 ->setLabel(pht('Acting User'));
18
19 $templates[] = id(new PhabricatorStringMailStamp())
20 ->setKey('via')
21 ->setLabel(pht('Via Content Source'));
22
23 $templates[] = id(new PhabricatorBoolMailStamp())
24 ->setKey('silent')
25 ->setLabel(pht('Silent Edit'));
26
27 $templates[] = id(new PhabricatorBoolMailStamp())
28 ->setKey('encrypted')
29 ->setLabel(pht('Encryption Required'));
30
31 $templates[] = id(new PhabricatorBoolMailStamp())
32 ->setKey('new')
33 ->setLabel(pht('New Object'));
34
35 $templates[] = id(new PhabricatorPHIDMailStamp())
36 ->setKey('mention')
37 ->setLabel(pht('Mentioned User'));
38
39 $templates[] = id(new PhabricatorStringMailStamp())
40 ->setKey('herald')
41 ->setLabel(pht('Herald Rule'));
42
43 $templates[] = id(new PhabricatorPHIDMailStamp())
44 ->setKey('removed')
45 ->setLabel(pht('Recipient Removed'));
46
47 return $templates;
48 }
49
50 public function newMailStamps($object, array $xactions) {
51 $editor = $this->getEditor();
52 $viewer = $this->getViewer();
53
54 $this->getMailStamp('actor')
55 ->setValue($editor->getActingAsPHID());
56
57 $content_source = $editor->getContentSource();
58 $this->getMailStamp('via')
59 ->setValue($content_source->getSourceTypeConstant());
60
61 $this->getMailStamp('silent')
62 ->setValue($editor->getIsSilent());
63
64 $this->getMailStamp('encrypted')
65 ->setValue($editor->getMustEncrypt());
66
67 $this->getMailStamp('new')
68 ->setValue($editor->getIsNewObject());
69
70 $mentioned_phids = $editor->getMentionedPHIDs();
71 $this->getMailStamp('mention')
72 ->setValue($mentioned_phids);
73
74 $this->getMailStamp('herald')
75 ->setValue($editor->getHeraldRuleMonograms());
76
77 $this->getMailStamp('removed')
78 ->setValue($editor->getRemovedRecipientPHIDs());
79 }
80
81}