summaryrefslogtreecommitdiffstats
path: root/lib/private/Activity
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-06-15 15:01:52 +0200
committerRobin Appelman <robin@icewind.nl>2020-07-21 17:12:38 +0200
commitfb5ae20722a29890535296c8871a2edf4201289d (patch)
tree9d05b74ad3f3abd3fbd9be81ef59d5288d741172 /lib/private/Activity
parentd35e8d7b2be708650037bc16f5be4122f5fa1082 (diff)
downloadnextcloud-server-fb5ae20722a29890535296c8871a2edf4201289d.tar.gz
nextcloud-server-fb5ae20722a29890535296c8871a2edf4201289d.zip
basic settings system for activity notifications
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Activity')
-rw-r--r--lib/private/Activity/ActivitySettingsAdapter.php57
-rw-r--r--lib/private/Activity/Event.php11
-rw-r--r--lib/private/Activity/Manager.php11
3 files changed, 75 insertions, 4 deletions
diff --git a/lib/private/Activity/ActivitySettingsAdapter.php b/lib/private/Activity/ActivitySettingsAdapter.php
new file mode 100644
index 00000000000..f5544debd78
--- /dev/null
+++ b/lib/private/Activity/ActivitySettingsAdapter.php
@@ -0,0 +1,57 @@
+<?php declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Activity;
+
+use OCP\Activity\ActivitySettings;
+use OCP\Activity\ISetting;
+
+/**
+ * Adapt the old interface based settings into the new abstract
+ * class based one
+ */
+class ActivitySettingsAdapter extends ActivitySettings {
+ private $oldSettings;
+
+ public function __construct(ISetting $oldSettings) {
+ $this->oldSettings = $oldSettings;
+ }
+
+ public function getIdentifier() {
+ return $this->oldSettings->getIdentifier();
+ }
+
+ public function getName() {
+ return $this->oldSettings->getName();
+ }
+
+ public function getPriority() {
+ return $this->oldSettings->getPriority();
+ }
+
+ public function canChangeMail() {
+ return $this->oldSettings->canChangeMail();
+ }
+
+ public function isDefaultEnabledMail() {
+ return $this->oldSettings->isDefaultEnabledMail();
+ }
+}
diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php
index 4958cdfd46e..5f82b37c91a 100644
--- a/lib/private/Activity/Event.php
+++ b/lib/private/Activity/Event.php
@@ -74,6 +74,8 @@ class Event implements IEvent {
protected $link = '';
/** @var string */
protected $icon = '';
+ /** @var bool */
+ protected $generateNotification = true;
/** @var IEvent|null */
protected $child;
@@ -532,4 +534,13 @@ class Event implements IEvent {
*/
;
}
+
+ public function setGenerateNotification(bool $generate): IEvent {
+ $this->generateNotification = $generate;
+ return $this;
+ }
+
+ public function getGenerateNotification(): bool {
+ return $this->generateNotification;
+ }
}
diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php
index ffe6c335b27..6c40f752bc8 100644
--- a/lib/private/Activity/Manager.php
+++ b/lib/private/Activity/Manager.php
@@ -28,6 +28,7 @@
namespace OC\Activity;
+use OCP\Activity\ActivitySettings;
use OCP\Activity\IConsumer;
use OCP\Activity\IEvent;
use OCP\Activity\IFilter;
@@ -262,7 +263,7 @@ class Manager implements IManager {
}
/**
- * @return ISetting[]
+ * @return ActivitySettings[]
* @throws \InvalidArgumentException
*/
public function getSettings(): array {
@@ -270,7 +271,9 @@ class Manager implements IManager {
/** @var ISetting $setting */
$setting = \OC::$server->query($class);
- if (!$setting instanceof ISetting) {
+ if ($setting instanceof ISetting) {
+ $setting = new ActivitySettingsAdapter($setting);
+ } else if (!$setting instanceof ActivitySettings) {
throw new \InvalidArgumentException('Invalid activity filter registered');
}
@@ -283,11 +286,11 @@ class Manager implements IManager {
/**
* @param string $id
- * @return ISetting
+ * @return ActivitySettings
* @throws \InvalidArgumentException when the setting was not found
* @since 11.0.0
*/
- public function getSettingById(string $id): ISetting {
+ public function getSettingById(string $id): ActivitySettings {
$settings = $this->getSettings();
if (isset($settings[$id])) {