From bf9a55de0ef39d08463a25f615622bb3a2fec95e Mon Sep 17 00:00:00 2001 From: Aerex Date: Fri, 31 Jul 2020 02:41:04 -0500 Subject: [PATCH] fix: Prevent importing calendar tasks if coming from taskwarrior cli --- README.md | 4 ++-- lib/Plugin.php | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2320c97..78bcc80 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ composer require aerex/baikal-storage-plugin ``` ## Configuration -Copy sample configuration to your baikal installation. Make sure that the folder is *writable* by your webserver (e.g Apache, Nginx) +Create the `config.yaml` to your webserver. Make sure the file is *writable* by your webserver (e.g Apache, Nginx). For more details on the configuration details see the wiki page. ## Usage - Add the plugin to `Core/Frameworks/Baikal/Core/Server.php` ``` -$this->server->addPlugin(new \Aerex\BaikalStorage\Plugin()) +$this->server->addPlugin(new \Aerex\BaikalStorage\Plugin()) ``` diff --git a/lib/Plugin.php b/lib/Plugin.php index 71c5352..449c718 100644 --- a/lib/Plugin.php +++ b/lib/Plugin.php @@ -114,6 +114,7 @@ class Plugin extends ServerPlugin { return; } } + @@ -127,12 +128,14 @@ class Plugin extends ServerPlugin { function httpPut(RequestInterface $request){ $body = $request->getBodyAsString(); $vCal = \Sabre\VObject\Reader::read($body); - try { - $this->storageManager->import($vCal); - } catch(BadRequest $e){ + if (!stristr($vCal->PRODID, 'taskwarrior')) { + try { + $this->storageManager->import($vCal); + } catch(BadRequest $e){ throw new BadRequest($e->getMessage(), null, $e); - } catch(\Exception $e){ + } catch(\Exception $e){ throw new \Exception($e->getMessage(), null, $e); + } } $request->setBody($body);