mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
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
This commit is contained in:
parent
1014a27717
commit
1e488e9277
3 changed files with 58 additions and 4 deletions
|
@ -2111,6 +2111,7 @@ phutil_register_library_map(array(
|
|||
'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 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhabricatorCalendarImportDefaultLogType' => 'PhabricatorCalendarImportLogType',
|
||||
'PhabricatorCalendarImportDeleteController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarImportDeleteLogType' => 'PhabricatorCalendarImportLogType',
|
||||
'PhabricatorCalendarImportDeleteTransaction' => 'PhabricatorCalendarImportTransactionType',
|
||||
'PhabricatorCalendarImportDisableController' => 'PhabricatorCalendarController',
|
||||
'PhabricatorCalendarImportDisableTransaction' => 'PhabricatorCalendarImportTransactionType',
|
||||
|
|
|
@ -409,10 +409,28 @@ abstract class PhabricatorCalendarImportEngine
|
|||
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) {
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue