Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15454616
D12645.id30368.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D12645.id30368.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1491,6 +1491,7 @@
'PhabricatorCalendarEventInviteeQuery' => 'applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php',
'PhabricatorCalendarEventJoinController' => 'applications/calendar/controller/PhabricatorCalendarEventJoinController.php',
'PhabricatorCalendarEventListController' => 'applications/calendar/controller/PhabricatorCalendarEventListController.php',
+ 'PhabricatorCalendarEventMailReceiver' => 'applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php',
'PhabricatorCalendarEventPHIDType' => 'applications/calendar/phid/PhabricatorCalendarEventPHIDType.php',
'PhabricatorCalendarEventQuery' => 'applications/calendar/query/PhabricatorCalendarEventQuery.php',
'PhabricatorCalendarEventSearchEngine' => 'applications/calendar/query/PhabricatorCalendarEventSearchEngine.php',
@@ -1502,6 +1503,7 @@
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php',
+ 'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php',
'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php',
'PhabricatorCalendarViewController' => 'applications/calendar/controller/PhabricatorCalendarViewController.php',
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
@@ -4830,6 +4832,7 @@
'PhabricatorCalendarEventInviteeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCalendarEventJoinController' => 'PhabricatorCalendarController',
'PhabricatorCalendarEventListController' => 'PhabricatorCalendarController',
+ 'PhabricatorCalendarEventMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorCalendarEventPHIDType' => 'PhabricatorPHIDType',
'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCalendarEventSearchEngine' => 'PhabricatorApplicationSearchEngine',
@@ -4841,6 +4844,7 @@
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule',
+ 'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'PhabricatorCalendarViewController' => 'PhabricatorCalendarController',
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php
@@ -209,10 +209,6 @@
return $errors;
}
- protected function getMailTo(PhabricatorLiskDAO $object) {
- return array($object->getUserPHID());
- }
-
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
@@ -222,4 +218,100 @@
protected function supportsSearch() {
return true;
}
+
+ protected function shouldSendMail(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+
+ $xactions = mfilter($xactions, 'shouldHide', true);
+ return $xactions;
+ }
+
+ protected function getMailSubjectPrefix() {
+ return pht('[CALENDAR]');
+ }
+
+ protected function getMailThreadID(PhabricatorLiskDAO $object) {
+ return 'calendar-event-'.$object->getPHID();
+ }
+
+ protected function getMailTo(PhabricatorLiskDAO $object) {
+ $phids = array();
+
+ if ($object->getUserPHID()) {
+ $phids[] = $object->getUserPHID();
+ }
+ $phids[] = $this->getActingAsPHID();
+
+ $invitees = $object->getInvitees();
+ foreach ($invitees as $phid => $status) {
+ if ($status === PhabricatorCalendarEventInvitee::STATUS_ATTENDING
+ || $status === PhabricatorCalendarEventInvitee::STATUS_INVITED) {
+ $phids[] = $phid;
+ }
+ }
+
+ $phids = array_unique($phids);
+ return $phids;
+ }
+
+ public function getMailTagsMap() {
+ return array(
+ ManiphestTransaction::MAILTAG_STATUS =>
+ pht("A task's status changes."),
+ ManiphestTransaction::MAILTAG_OWNER =>
+ pht("A task's owner changes."),
+ ManiphestTransaction::MAILTAG_PRIORITY =>
+ pht("A task's priority changes."),
+ ManiphestTransaction::MAILTAG_CC =>
+ pht("A task's subscribers change."),
+ ManiphestTransaction::MAILTAG_PROJECTS =>
+ pht("A task's associated projects change."),
+ ManiphestTransaction::MAILTAG_UNBLOCK =>
+ pht('One of the tasks a task is blocked by changes status.'),
+ ManiphestTransaction::MAILTAG_COLUMN =>
+ pht('A task is moved between columns on a workboard.'),
+ ManiphestTransaction::MAILTAG_COMMENT =>
+ pht('Someone comments on a task.'),
+ ManiphestTransaction::MAILTAG_OTHER =>
+ pht('Other task activity not listed above occurs.'),
+ );
+ }
+
+ protected function buildReplyHandler(PhabricatorLiskDAO $object) {
+ return id(new PhabricatorCalendarReplyHandler())
+ ->setMailReceiver($object);
+ }
+
+ protected function buildMailTemplate(PhabricatorLiskDAO $object) {
+ $id = $object->getID();
+ $name = $object->getName();
+
+ return id(new PhabricatorMetaMTAMail())
+ ->setSubject("E{$id}: {$name}")
+ ->addHeader('Thread-Topic', "E{$id}: ".$object->getName());
+ }
+
+ protected function buildMailBody(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+
+ $description = $object->getDescription();
+ $body = parent::buildMailBody($object, $xactions);
+
+ if (strlen($description)) {
+ $body->addTextSection(
+ pht('EVENT DESCRIPTION'),
+ $object->getDescription());
+ }
+
+ $body->addLinkSection(
+ pht('EVENT DETAIL'),
+ PhabricatorEnv::getProductionURI('/E'.$object->getID()));
+
+
+ return $body;
+ }
+
+
}
diff --git a/src/applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php b/src/applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/mail/PhabricatorCalendarEventMailReceiver.php
@@ -0,0 +1,28 @@
+<?php
+
+final class PhabricatorCalendarEventMailReceiver
+ extends PhabricatorObjectMailReceiver {
+
+ public function isEnabled() {
+ $app_class = 'PhabricatorCalendarApplication';
+ return PhabricatorApplication::isClassInstalled($app_class);
+ }
+
+ protected function getObjectPattern() {
+ return 'E[1-9]\d*';
+ }
+
+ protected function loadObject($pattern, PhabricatorUser $viewer) {
+ $id = (int)trim($pattern, 'E');
+
+ return id(new PhabricatorCalendarEventQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->executeOne();
+ }
+
+ protected function getTransactionReplyHandler() {
+ return new PhabricatorCalendarReplyHandler();
+ }
+
+}
diff --git a/src/applications/calendar/mail/PhabricatorCalendarReplyHandler.php b/src/applications/calendar/mail/PhabricatorCalendarReplyHandler.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/mail/PhabricatorCalendarReplyHandler.php
@@ -0,0 +1,15 @@
+<?php
+
+final class PhabricatorCalendarReplyHandler
+ extends PhabricatorApplicationTransactionReplyHandler {
+
+ public function validateMailReceiver($mail_receiver) {
+ if (!($mail_receiver instanceof PhabricatorCalendarEvent)) {
+ throw new Exception('Mail receiver is not a PhabricatorCalendarEvent!');
+ }
+ }
+
+ public function getObjectPrefix() {
+ return 'E';
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 7:23 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7711707
Default Alt Text
D12645.id30368.diff (7 KB)
Attached To
Mode
D12645: Calendar event transaction emails without reply handling
Attached
Detach File
Event Timeline
Log In to Comment