feat: Added deleting task when ical todo delete has been sent
- feat: Added warn logger method to logger class
This commit is contained in:
@@ -6,6 +6,7 @@ use Sabre\VObject\Component\VCalendar as Calendar;
|
||||
|
||||
interface IStorage {
|
||||
public function save(Calendar $c);
|
||||
public function remove($uid);
|
||||
public function refresh();
|
||||
public function getConfigBrowser();
|
||||
public function updateConfigs($postData);
|
||||
|
@@ -98,13 +98,13 @@ class Taskwarrior implements IStorage {
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_push(['description' => $descriptionLine, 'entry' => $annotationEntry]);
|
||||
array_push($annotations, ['description' => $descriptionLine, 'entry' => $annotationEntry]);
|
||||
$task['annotations'] = $annotations;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($task['entry'])){
|
||||
$task['entry'] = $vtodo->DTSTAMP->getDateTime()->format(\DateTime::ISO8601);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($vtodo->DTSTART)) {
|
||||
$task['start'] = $vtodo->DTSTART->getDateTime()->format(\DateTime::ISO8601);
|
||||
@@ -177,11 +177,6 @@ class Taskwarrior implements IStorage {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($vtodo->{'RELATED-TO'}) && isset($this->tasks[(string)$vtodo->{'RELATED-TO'}])) {
|
||||
$relatedTask = $this->tasks[(string)$vtodo->{'RELATED-TO'}];
|
||||
$task['depends'] = $relatedTask['uuid'];
|
||||
}
|
||||
|
||||
if (isset($vtodo->GEO)){
|
||||
$task['geo'] = $vtodo->GEO->getRawMimeDirValue();
|
||||
}
|
||||
@@ -209,4 +204,31 @@ class Taskwarrior implements IStorage {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($uid) {
|
||||
try {
|
||||
$this->logger->info(sprintf('Deleting iCal %s from taskwarrior', $uid));
|
||||
$this->refresh();
|
||||
$task = $this->tasks[(string)$uid];
|
||||
if (isset($task) && $task['status'] !== 'deleted') {
|
||||
$uuid = $task['uuid'];
|
||||
$this->logger->info(
|
||||
sprintf('Executing TASKRC = %s TASKDATA = %s task delete %s', $this->configs['taskrc'], $this->configs['taskdata'], $uuid)
|
||||
);
|
||||
$output = $this->console->execute('task', ['delete', (string)$uuid], null,
|
||||
['TASKRC' => $this->configs['taskrc'],'TASKDATA' => $this->configs['taskdata']]);
|
||||
$this->logger->info($output);
|
||||
} else if (isset($task) && $task['status'] === 'deleted') {
|
||||
$this->logger->warn(sprintf('Task %s has already been deleted', $task['uuid']));
|
||||
} else {
|
||||
$this->logger->error(sprintf('Could not find task for iCal %s to be deleted', $uid));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
$this->logger->error($e->getTraceAsString());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user