Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15339145
D16768.id40384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D16768.id40384.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
@@ -2111,6 +2111,7 @@
'PhabricatorCalendarImport' => 'applications/calendar/storage/PhabricatorCalendarImport.php',
'PhabricatorCalendarImportDefaultLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportDefaultLogType.php',
'PhabricatorCalendarImportDeleteController' => 'applications/calendar/controller/PhabricatorCalendarImportDeleteController.php',
+ 'PhabricatorCalendarImportDeleteLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php',
'PhabricatorCalendarImportDeleteTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportDeleteTransaction.php',
'PhabricatorCalendarImportDisableController' => 'applications/calendar/controller/PhabricatorCalendarImportDisableController.php',
'PhabricatorCalendarImportDisableTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportDisableTransaction.php',
@@ -6965,6 +6966,7 @@
),
'PhabricatorCalendarImportDefaultLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportDeleteController' => 'PhabricatorCalendarController',
+ 'PhabricatorCalendarImportDeleteLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportDeleteTransaction' => 'PhabricatorCalendarImportTransactionType',
'PhabricatorCalendarImportDisableController' => 'PhabricatorCalendarController',
'PhabricatorCalendarImportDisableTransaction' => 'PhabricatorCalendarImportTransactionType',
diff --git a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
@@ -409,10 +409,28 @@
array());
}
- // TODO: When the source is a subscription-based ICS file or some other
- // similar source, we should load all events from the source here and
- // destroy the ones we didn't update. These are events that have been
- // deleted.
+ // Delete any events which are no longer present in the source.
+ $updated_events = mpull($update_map, null, 'getPHID');
+ $source_events = id(new PhabricatorCalendarEventQuery())
+ ->setViewer($viewer)
+ ->withImportSourcePHIDs(array($import->getPHID()))
+ ->execute();
+
+ $engine = new PhabricatorDestructionEngine();
+ foreach ($source_events as $source_event) {
+ if (isset($updated_events[$source_event->getPHID()])) {
+ // We imported and updated this event, so keep it around.
+ continue;
+ }
+
+ $import->newLogMessage(
+ PhabricatorCalendarImportDeleteLogType::LOGTYPE,
+ array(
+ 'name' => $source_event->getName(),
+ ));
+
+ $engine->destroyObject($source_event);
+ }
}
private function getFullNodeUID(PhutilCalendarEventNode $node) {
diff --git a/src/applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php b/src/applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php
@@ -0,0 +1,34 @@
+<?php
+
+final class PhabricatorCalendarImportDeleteLogType
+ extends PhabricatorCalendarImportLogType {
+
+ const LOGTYPE = 'delete';
+
+ public function getDisplayType(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return pht('Deleted Event');
+ }
+
+ public function getDisplayDescription(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return pht(
+ 'Deleted event "%s" which is no longer present in the source.',
+ $log->getParameter('name'));
+ }
+
+ public function getDisplayIcon(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return 'fa-times';
+ }
+
+ public function getDisplayColor(
+ PhabricatorUser $viewer,
+ PhabricatorCalendarImportLog $log) {
+ return 'grey';
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 10, 2:31 PM (2 w, 46 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7384179
Default Alt Text
D16768.id40384.diff (4 KB)
Attached To
Mode
D16768: When importing events, delete events which have been removed on the other end
Attached
Detach File
Event Timeline
Log In to Comment