mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Make .ics export less scary and attach .ics files to event mail
Summary: Ref T10747. - Remove the warning dialog since these files don't seem to do anything confusing/problematic in Calendar.app or Google Calendar. Those importers generally need to be defensive about how they handle random ".ics" files from arbitrary third parties anyway, and this makes testing imports easier since we have a GET-table ".ics" URI for public events. - Attach ".ics" files to email. Test Plan: - Clicked "Export as .ics", got an ICS file. - Used "bin/mail show-outbound" to review an ICS attachment, although I don't actually have real mail set up locally so this may still be a little funky. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10747 Differential Revision: https://secure.phabricator.com/D16559
This commit is contained in:
parent
96f800249b
commit
3d6c3c2c45
5 changed files with 43 additions and 30 deletions
|
@ -59,7 +59,7 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication {
|
||||||
=> 'PhabricatorCalendarEventCancelController',
|
=> 'PhabricatorCalendarEventCancelController',
|
||||||
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
|
'(?P<action>join|decline|accept)/(?P<id>[1-9]\d*)/'
|
||||||
=> 'PhabricatorCalendarEventJoinController',
|
=> 'PhabricatorCalendarEventJoinController',
|
||||||
'export/(?P<id>[1-9]\d*)/'
|
'export/(?P<id>[1-9]\d*)/(?P<filename>[^/]*)'
|
||||||
=> 'PhabricatorCalendarEventExportController',
|
=> 'PhabricatorCalendarEventExportController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -19,9 +19,7 @@ final class PhabricatorCalendarEventExportController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
$file_name = $event->getICSFilename();
|
||||||
$file_name = $event->getMonogram().'.ics';
|
|
||||||
|
|
||||||
$event_node = $event->newIntermediateEventNode($viewer);
|
$event_node = $event->newIntermediateEventNode($viewer);
|
||||||
|
|
||||||
$document_node = id(new PhutilCalendarDocumentNode())
|
$document_node = id(new PhutilCalendarDocumentNode())
|
||||||
|
@ -39,16 +37,4 @@ final class PhabricatorCalendarEventExportController
|
||||||
->setContent($ics_data);
|
->setContent($ics_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->newDialog()
|
|
||||||
->setDisableWorkflowOnSubmit(true)
|
|
||||||
->setTitle(pht('Export as .ics'))
|
|
||||||
->appendParagraph(
|
|
||||||
pht(
|
|
||||||
'WARNING: This feature is a prototype and only supports a limited '.
|
|
||||||
'set of features. Keep your expectations low!'))
|
|
||||||
->addSubmitButton(pht('Download .ics'))
|
|
||||||
->addCancelButton($event->getURI(), pht('Close'));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,14 +193,14 @@ final class PhabricatorCalendarEventViewController
|
||||||
->setWorkflow(true));
|
->setWorkflow(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$export_uri = $this->getApplicationURI("event/export/{$id}/");
|
$ics_name = $event->getICSFilename();
|
||||||
|
$export_uri = $this->getApplicationURI("event/export/{$id}/{$ics_name}");
|
||||||
|
|
||||||
$curtain->addAction(
|
$curtain->addAction(
|
||||||
id(new PhabricatorActionView())
|
id(new PhabricatorActionView())
|
||||||
->setName(pht('Export as .ics'))
|
->setName(pht('Export as .ics'))
|
||||||
->setIcon('fa-download')
|
->setIcon('fa-download')
|
||||||
->setHref($export_uri)
|
->setHref($export_uri));
|
||||||
->setWorkflow(true));
|
|
||||||
|
|
||||||
return $curtain;
|
return $curtain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,6 +285,8 @@ final class PhabricatorCalendarEventEditor
|
||||||
pht('EVENT DETAIL'),
|
pht('EVENT DETAIL'),
|
||||||
PhabricatorEnv::getProductionURI('/E'.$object->getID()));
|
PhabricatorEnv::getProductionURI('/E'.$object->getID()));
|
||||||
|
|
||||||
|
$ics_attachment = $this->newICSAttachment($object);
|
||||||
|
$body->addAttachment($ics_attachment);
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
@ -303,5 +305,27 @@ final class PhabricatorCalendarEventEditor
|
||||||
->setObject($object);
|
->setObject($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function newICSAttachment(
|
||||||
|
PhabricatorCalendarEvent $event) {
|
||||||
|
$actor = $this->getActor();
|
||||||
|
|
||||||
|
$event_node = $event->newIntermediateEventNode($actor);
|
||||||
|
|
||||||
|
$document_node = id(new PhutilCalendarDocumentNode())
|
||||||
|
->appendChild($event_node);
|
||||||
|
|
||||||
|
$root_node = id(new PhutilCalendarRootNode())
|
||||||
|
->appendChild($document_node);
|
||||||
|
|
||||||
|
$ics_data = id(new PhutilICSWriter())
|
||||||
|
->writeICSDocument($root_node);
|
||||||
|
|
||||||
|
$ics_attachment = new PhabricatorMetaMTAAttachment(
|
||||||
|
$ics_data,
|
||||||
|
$event->getICSFilename(),
|
||||||
|
'text/calendar');
|
||||||
|
|
||||||
|
return $ics_attachment;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,6 +625,9 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getICSFilename() {
|
||||||
|
return $this->getMonogram().'.ics';
|
||||||
|
}
|
||||||
|
|
||||||
public function newIntermediateEventNode(PhabricatorUser $viewer) {
|
public function newIntermediateEventNode(PhabricatorUser $viewer) {
|
||||||
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
|
$base_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
|
||||||
|
|
Loading…
Reference in a new issue