@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

When importing events, delete events which have been removed on the other end

Summary: Ref T10747. If stuff has been deleted on the other calendar, delete it on ours.

Test Plan:
Imported with deletion, saw deletions:

{F1889689}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10747

Differential Revision: https://secure.phabricator.com/D16768

+58 -4
+2
src/__phutil_library_map__.php
··· 2111 2111 'PhabricatorCalendarImport' => 'applications/calendar/storage/PhabricatorCalendarImport.php', 2112 2112 'PhabricatorCalendarImportDefaultLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportDefaultLogType.php', 2113 2113 'PhabricatorCalendarImportDeleteController' => 'applications/calendar/controller/PhabricatorCalendarImportDeleteController.php', 2114 + 'PhabricatorCalendarImportDeleteLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php', 2114 2115 'PhabricatorCalendarImportDeleteTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportDeleteTransaction.php', 2115 2116 'PhabricatorCalendarImportDisableController' => 'applications/calendar/controller/PhabricatorCalendarImportDisableController.php', 2116 2117 'PhabricatorCalendarImportDisableTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportDisableTransaction.php', ··· 6965 6966 ), 6966 6967 'PhabricatorCalendarImportDefaultLogType' => 'PhabricatorCalendarImportLogType', 6967 6968 'PhabricatorCalendarImportDeleteController' => 'PhabricatorCalendarController', 6969 + 'PhabricatorCalendarImportDeleteLogType' => 'PhabricatorCalendarImportLogType', 6968 6970 'PhabricatorCalendarImportDeleteTransaction' => 'PhabricatorCalendarImportTransactionType', 6969 6971 'PhabricatorCalendarImportDisableController' => 'PhabricatorCalendarController', 6970 6972 'PhabricatorCalendarImportDisableTransaction' => 'PhabricatorCalendarImportTransactionType',
+22 -4
src/applications/calendar/import/PhabricatorCalendarImportEngine.php
··· 409 409 array()); 410 410 } 411 411 412 - // TODO: When the source is a subscription-based ICS file or some other 413 - // similar source, we should load all events from the source here and 414 - // destroy the ones we didn't update. These are events that have been 415 - // deleted. 412 + // Delete any events which are no longer present in the source. 413 + $updated_events = mpull($update_map, null, 'getPHID'); 414 + $source_events = id(new PhabricatorCalendarEventQuery()) 415 + ->setViewer($viewer) 416 + ->withImportSourcePHIDs(array($import->getPHID())) 417 + ->execute(); 418 + 419 + $engine = new PhabricatorDestructionEngine(); 420 + foreach ($source_events as $source_event) { 421 + if (isset($updated_events[$source_event->getPHID()])) { 422 + // We imported and updated this event, so keep it around. 423 + continue; 424 + } 425 + 426 + $import->newLogMessage( 427 + PhabricatorCalendarImportDeleteLogType::LOGTYPE, 428 + array( 429 + 'name' => $source_event->getName(), 430 + )); 431 + 432 + $engine->destroyObject($source_event); 433 + } 416 434 } 417 435 418 436 private function getFullNodeUID(PhutilCalendarEventNode $node) {
+34
src/applications/calendar/importlog/PhabricatorCalendarImportDeleteLogType.php
··· 1 + <?php 2 + 3 + final class PhabricatorCalendarImportDeleteLogType 4 + extends PhabricatorCalendarImportLogType { 5 + 6 + const LOGTYPE = 'delete'; 7 + 8 + public function getDisplayType( 9 + PhabricatorUser $viewer, 10 + PhabricatorCalendarImportLog $log) { 11 + return pht('Deleted Event'); 12 + } 13 + 14 + public function getDisplayDescription( 15 + PhabricatorUser $viewer, 16 + PhabricatorCalendarImportLog $log) { 17 + return pht( 18 + 'Deleted event "%s" which is no longer present in the source.', 19 + $log->getParameter('name')); 20 + } 21 + 22 + public function getDisplayIcon( 23 + PhabricatorUser $viewer, 24 + PhabricatorCalendarImportLog $log) { 25 + return 'fa-times'; 26 + } 27 + 28 + public function getDisplayColor( 29 + PhabricatorUser $viewer, 30 + PhabricatorCalendarImportLog $log) { 31 + return 'grey'; 32 + } 33 + 34 + }