From 7223a19ad3d507afd77a81640f9d95508a36802e Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Thu, 5 Sep 2024 16:02:45 +0600 Subject: [PATCH] feat: add nexcloud contacts app requirement on nextcloud plugin Nextcloud plugin can ask user to choose addressbook to let automatically save the recipients. But it is dependent on https://github.com/nextcloud/contacts/ to be installed at NC server. This commit add the check before showing the option to the user. --- plugins/nextcloud/README.md | 2 +- plugins/nextcloud/index.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/nextcloud/README.md b/plugins/nextcloud/README.md index fc2c6ed37..0592c5073 100644 --- a/plugins/nextcloud/README.md +++ b/plugins/nextcloud/README.md @@ -2,7 +2,7 @@ ## Nextcloud Addressbook for recipients -This plugin can let user to choose which nextcloud addressbook to use save recipients. This is opt-in feature (enabled by admin). After admin enable this, user will find a dropdown in his/her SnappyMail's `Contacts` section, containing all his/her addressbook. +If server has [Nextcloud Contacts App](https://github.com/nextcloud/contacts/) setup, this plugin can let user to choose which nextcloud addressbook to use save recipients. This is opt-in feature (enabled by admin). After admin enable this, user will find a dropdown in his/her SnappyMail's `Contacts` section, containing all his/her addressbook. ### Admin settings diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php index 578604345..371f72cd9 100644 --- a/plugins/nextcloud/index.php +++ b/plugins/nextcloud/index.php @@ -62,7 +62,7 @@ public function Init() : void $this->addHook('smtp.before-login', 'beforeLogin'); $this->addHook('sieve.before-login', 'beforeLogin'); - if ($this->Config()->Get('plugin', self::ENABLE_NC_ADDRESSBOOK_KEY, self::ENABLE_NC_ADDRESSBOOK_DEFAULT_VALUE)) { + if ($this->isNcContatcsAppSetup() && $this->Config()->Get('plugin', self::ENABLE_NC_ADDRESSBOOK_KEY, self::ENABLE_NC_ADDRESSBOOK_DEFAULT_VALUE)) { $this->addJs('js/nextcloudAddressbook.js'); $this->addJsonHook('NextcloudGetAddressBooks', 'GetAddressBooks'); $this->addJsonHook('NextcloudUpdateAddressBook', 'UpdateAddressBook'); @@ -556,6 +556,10 @@ private function UserSettings() : \RainLoop\Settings { return $this->SettingsProvider()->Load($this->Account()); } + + private function isNcContatcsAppSetup() : bool { + return \OC::$server->getAppManager()->isEnabledForUser('contacts'); + } } class AddressBook