Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phame / editor / PhamePostEditor.php
blob61092114d1dde2200e434c6efc3fa7cd10df1a7d
1 <?php
3 final class PhamePostEditor
4 extends PhabricatorApplicationTransactionEditor {
6 public function getEditorApplicationClass() {
7 return 'PhabricatorPhameApplication';
10 public function getEditorObjectsDescription() {
11 return pht('Phame Posts');
14 public function getCreateObjectTitle($author, $object) {
15 return pht('%s created this post.', $author);
18 public function getCreateObjectTitleForFeed($author, $object) {
19 return pht('%s created %s.', $author, $object);
22 public function getTransactionTypes() {
23 $types = parent::getTransactionTypes();
25 $types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY;
26 $types[] = PhabricatorTransactions::TYPE_COMMENT;
28 return $types;
31 protected function shouldSendMail(
32 PhabricatorLiskDAO $object,
33 array $xactions) {
34 if ($object->isDraft() || ($object->isArchived())) {
35 return false;
37 return true;
40 protected function shouldPublishFeedStory(
41 PhabricatorLiskDAO $object,
42 array $xactions) {
43 if ($object->isDraft() || $object->isArchived()) {
44 return false;
46 return true;
49 protected function getMailTo(PhabricatorLiskDAO $object) {
50 $phids = array();
51 $phids[] = $object->getBloggerPHID();
52 $phids[] = $this->requireActor()->getPHID();
54 $blog_phid = $object->getBlogPHID();
55 if ($blog_phid) {
56 $cc_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID(
57 $blog_phid);
58 foreach ($cc_phids as $cc) {
59 $phids[] = $cc;
62 return $phids;
65 protected function buildMailTemplate(PhabricatorLiskDAO $object) {
66 $title = $object->getTitle();
68 return id(new PhabricatorMetaMTAMail())
69 ->setSubject($title);
72 protected function buildReplyHandler(PhabricatorLiskDAO $object) {
73 return id(new PhamePostReplyHandler())
74 ->setMailReceiver($object);
77 protected function buildMailBody(
78 PhabricatorLiskDAO $object,
79 array $xactions) {
81 $body = parent::buildMailBody($object, $xactions);
83 // We don't send mail if the object is a draft, and we only want
84 // to include the full body of the post on the either the
85 // first creation or if it was created as a draft, once it goes live.
86 if ($this->getIsNewObject()) {
87 $body->addRemarkupSection(null, $object->getBody());
88 } else {
89 foreach ($xactions as $xaction) {
90 switch ($xaction->getTransactionType()) {
91 case PhamePostVisibilityTransaction::TRANSACTIONTYPE:
92 if (!$object->isDraft() && !$object->isArchived()) {
93 $body->addRemarkupSection(null, $object->getBody());
95 break;
100 $body->addLinkSection(
101 pht('POST DETAIL'),
102 PhabricatorEnv::getProductionURI($object->getViewURI()));
104 return $body;
107 public function getMailTagsMap() {
108 return array(
109 PhamePostTransaction::MAILTAG_CONTENT =>
110 pht("A post's content changes."),
111 PhamePostTransaction::MAILTAG_SUBSCRIBERS =>
112 pht("A post's subscribers change."),
113 PhamePostTransaction::MAILTAG_COMMENT =>
114 pht('Someone comments on a post.'),
115 PhamePostTransaction::MAILTAG_OTHER =>
116 pht('Other post activity not listed above occurs.'),
120 protected function getMailSubjectPrefix() {
121 return '[Phame]';
124 protected function supportsSearch() {
125 return true;
128 protected function shouldApplyHeraldRules(
129 PhabricatorLiskDAO $object,
130 array $xactions) {
131 return true;
134 protected function buildHeraldAdapter(
135 PhabricatorLiskDAO $object,
136 array $xactions) {
138 return id(new HeraldPhamePostAdapter())
139 ->setPost($object);