Skip to content

Commit

Permalink
feat: add nexcloud contacts app requirement on nextcloud plugin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Fahim Salam Chowdhury committed Sep 5, 2024
1 parent 098cc82 commit 7223a19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion plugins/nextcloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7223a19

Please sign in to comment.