aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Activity')
-rw-r--r--lib/public/Activity/ActivitySettings.php25
-rw-r--r--lib/public/Activity/Exceptions/FilterNotFoundException.php31
-rw-r--r--lib/public/Activity/Exceptions/IncompleteActivityException.php26
-rw-r--r--lib/public/Activity/Exceptions/InvalidValueException.php32
-rw-r--r--lib/public/Activity/Exceptions/SettingNotFoundException.php31
-rw-r--r--lib/public/Activity/Exceptions/UnknownActivityException.php16
-rw-r--r--lib/public/Activity/IBulkConsumer.php24
-rw-r--r--lib/public/Activity/IConsumer.php27
-rw-r--r--lib/public/Activity/IEvent.php104
-rw-r--r--lib/public/Activity/IEventMerger.php25
-rw-r--r--lib/public/Activity/IExtension.php56
-rw-r--r--lib/public/Activity/IFilter.php27
-rw-r--r--lib/public/Activity/IManager.php56
-rw-r--r--lib/public/Activity/IProvider.php31
-rw-r--r--lib/public/Activity/ISetting.php27
15 files changed, 306 insertions, 232 deletions
diff --git a/lib/public/Activity/ActivitySettings.php b/lib/public/Activity/ActivitySettings.php
index 44e20c5396a..fa187164e19 100644
--- a/lib/public/Activity/ActivitySettings.php
+++ b/lib/public/Activity/ActivitySettings.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
- *
- * @author 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/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Activity;
@@ -55,8 +38,8 @@ abstract class ActivitySettings implements ISetting {
/**
* @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The filters are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
* @since 20.0.0
*/
abstract public function getPriority();
diff --git a/lib/public/Activity/Exceptions/FilterNotFoundException.php b/lib/public/Activity/Exceptions/FilterNotFoundException.php
new file mode 100644
index 00000000000..e3461f9b3e3
--- /dev/null
+++ b/lib/public/Activity/Exceptions/FilterNotFoundException.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class FilterNotFoundException extends \InvalidArgumentException {
+ /**
+ * @since 30.0.0
+ */
+ public function __construct(
+ protected string $filter,
+ ) {
+ parent::__construct('Filter ' . $filter . ' not found');
+ }
+
+ /**
+ * @since 30.0.0
+ */
+ public function getFilterId(): string {
+ return $this->filter;
+ }
+}
diff --git a/lib/public/Activity/Exceptions/IncompleteActivityException.php b/lib/public/Activity/Exceptions/IncompleteActivityException.php
new file mode 100644
index 00000000000..44f6b4aba58
--- /dev/null
+++ b/lib/public/Activity/Exceptions/IncompleteActivityException.php
@@ -0,0 +1,26 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * Thrown when {@see \OCP\Notification\IManager::notify()} is called with a notification
+ * that does not have all required fields set:
+ *
+ * - app
+ * - type
+ * - affectedUser
+ * - subject
+ * - objectType
+ * - objectId
+ *
+ * @since 30.0.0
+ */
+class IncompleteActivityException extends \BadMethodCallException {
+}
diff --git a/lib/public/Activity/Exceptions/InvalidValueException.php b/lib/public/Activity/Exceptions/InvalidValueException.php
new file mode 100644
index 00000000000..aa4b04ab199
--- /dev/null
+++ b/lib/public/Activity/Exceptions/InvalidValueException.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class InvalidValueException extends \InvalidArgumentException {
+ /**
+ * @since 30.0.0
+ */
+ public function __construct(
+ protected string $field,
+ ?\Throwable $previous = null,
+ ) {
+ parent::__construct('Value provided for ' . $field . ' is not valid', previous: $previous);
+ }
+
+ /**
+ * @since 30.0.0
+ */
+ public function getFieldIdentifier(): string {
+ return $this->field;
+ }
+}
diff --git a/lib/public/Activity/Exceptions/SettingNotFoundException.php b/lib/public/Activity/Exceptions/SettingNotFoundException.php
new file mode 100644
index 00000000000..d0847c19cd2
--- /dev/null
+++ b/lib/public/Activity/Exceptions/SettingNotFoundException.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class SettingNotFoundException extends \InvalidArgumentException {
+ /**
+ * @since 30.0.0
+ */
+ public function __construct(
+ protected string $setting,
+ ) {
+ parent::__construct('Setting ' . $setting . ' not found');
+ }
+
+ /**
+ * @since 30.0.0
+ */
+ public function getSettingId(): string {
+ return $this->setting;
+ }
+}
diff --git a/lib/public/Activity/Exceptions/UnknownActivityException.php b/lib/public/Activity/Exceptions/UnknownActivityException.php
new file mode 100644
index 00000000000..5567ddf2534
--- /dev/null
+++ b/lib/public/Activity/Exceptions/UnknownActivityException.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity\Exceptions;
+
+/**
+ * @since 30.0.0
+ */
+class UnknownActivityException extends \InvalidArgumentException {
+}
diff --git a/lib/public/Activity/IBulkConsumer.php b/lib/public/Activity/IBulkConsumer.php
new file mode 100644
index 00000000000..9fdf3516b9a
--- /dev/null
+++ b/lib/public/Activity/IBulkConsumer.php
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Activity;
+
+/**
+ * Interface IBulkConsumer
+ *
+ * @since 32.0.0
+ */
+interface IBulkConsumer extends IConsumer {
+ /**
+ * @param IEvent $event
+ * @param array $affectedUserIds
+ * @param ISetting $setting
+ * @return void
+ * @since 32.0.0
+ */
+ public function bulkReceive(IEvent $event, array $affectedUserIds, ISetting $setting): void;
+}
diff --git a/lib/public/Activity/IConsumer.php b/lib/public/Activity/IConsumer.php
index 69261d7e3ad..4cf35ea5a44 100644
--- a/lib/public/Activity/IConsumer.php
+++ b/lib/public/Activity/IConsumer.php
@@ -1,29 +1,12 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
+// This means that they should be used by apps instead of the internal Nextcloud classes
namespace OCP\Activity;
diff --git a/lib/public/Activity/IEvent.php b/lib/public/Activity/IEvent.php
index 1e3c1deef26..6014b75123c 100644
--- a/lib/public/Activity/IEvent.php
+++ b/lib/public/Activity/IEvent.php
@@ -3,33 +3,17 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
+// This means that they should be used by apps instead of the internal Nextcloud classes
namespace OCP\Activity;
+use OCP\Activity\Exceptions\InvalidValueException;
+
/**
* Interface IEvent
*
@@ -41,8 +25,9 @@ interface IEvent {
*
* @param string $app
* @return IEvent
- * @throws \InvalidArgumentException if the app id is invalid
+ * @throws InvalidValueException if the app id is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setApp(string $app): self;
@@ -51,28 +36,31 @@ interface IEvent {
*
* @param string $type
* @return IEvent
- * @throws \InvalidArgumentException if the type is invalid
+ * @throws InvalidValueException if the type is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setType(string $type): self;
/**
* Set the affected user of the activity
*
- * @param string $user
+ * @param string $affectedUser
* @return IEvent
- * @throws \InvalidArgumentException if the affected user is invalid
+ * @throws InvalidValueException if the affected user is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
- public function setAffectedUser(string $user): self;
+ public function setAffectedUser(string $affectedUser): self;
/**
* Set the author of the activity
*
* @param string $author
* @return IEvent
- * @throws \InvalidArgumentException if the author is invalid
+ * @throws InvalidValueException if the author is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setAuthor(string $author): self;
@@ -81,8 +69,9 @@ interface IEvent {
*
* @param int $timestamp
* @return IEvent
- * @throws \InvalidArgumentException if the timestamp is invalid
+ * @throws InvalidValueException if the timestamp is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setTimestamp(int $timestamp): self;
@@ -92,8 +81,9 @@ interface IEvent {
* @param string $subject
* @param array $parameters
* @return IEvent
- * @throws \InvalidArgumentException if the subject or parameters are invalid
+ * @throws InvalidValueException if the subject or parameters are invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setSubject(string $subject, array $parameters = []): self;
@@ -103,16 +93,15 @@ interface IEvent {
* HTML is not allowed in the parsed subject and will be escaped
* automatically by the clients. You can use the RichObjectString system
* provided by the Nextcloud server to highlight important parameters via
- * the setRichSubject method, but make sure, that a plain text message is
- * always set via setParsedSubject, to support clients which can not handle
- * rich strings.
+ * the setRichSubject method.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $subject
* @return $this
- * @throws \InvalidArgumentException if the subject is invalid
+ * @throws InvalidValueException if the subject is invalid
* @since 11.0.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setParsedSubject(string $subject): self;
@@ -128,16 +117,15 @@ interface IEvent {
* HTML is not allowed in the rich subject and will be escaped automatically
* by the clients, but you can use the RichObjectString system provided by
* the Nextcloud server to highlight important parameters.
- * Also make sure, that a plain text subject is always set via
- * setParsedSubject, to support clients which can not handle rich strings.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $subject
- * @param array $parameters
+ * @param array<string, array<string, string>> $parameters
* @return $this
- * @throws \InvalidArgumentException if the subject or parameters are invalid
+ * @throws InvalidValueException if the subject or parameters are invalid
* @since 11.0.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setRichSubject(string $subject, array $parameters = []): self;
@@ -148,7 +136,7 @@ interface IEvent {
public function getRichSubject(): string;
/**
- * @return array[]
+ * @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichSubjectParameters(): array;
@@ -159,8 +147,9 @@ interface IEvent {
* @param string $message
* @param array $parameters
* @return IEvent
- * @throws \InvalidArgumentException if the message or parameters are invalid
+ * @throws InvalidValueException if the message or parameters are invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setMessage(string $message, array $parameters = []): self;
@@ -170,16 +159,15 @@ interface IEvent {
* HTML is not allowed in the parsed message and will be escaped
* automatically by the clients. You can use the RichObjectString system
* provided by the Nextcloud server to highlight important parameters via
- * the setRichMessage method, but make sure, that a plain text message is
- * always set via setParsedMessage, to support clients which can not handle
- * rich strings.
+ * the setRichMessage method.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $message
* @return $this
- * @throws \InvalidArgumentException if the message is invalid
+ * @throws InvalidValueException if the message is invalid
* @since 11.0.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setParsedMessage(string $message): self;
@@ -195,16 +183,15 @@ interface IEvent {
* HTML is not allowed in the rich message and will be escaped automatically
* by the clients, but you can use the RichObjectString system provided by
* the Nextcloud server to highlight important parameters.
- * Also make sure, that a plain text message is always set via
- * setParsedMessage, to support clients which can not handle rich strings.
*
* See https://github.com/nextcloud/server/issues/1706 for more information.
*
* @param string $message
- * @param array $parameters
+ * @param array<string, array<string, string>> $parameters
* @return $this
* @throws \InvalidArgumentException if the message or parameters are invalid
* @since 11.0.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setRichMessage(string $message, array $parameters = []): self;
@@ -215,7 +202,7 @@ interface IEvent {
public function getRichMessage(): string;
/**
- * @return array[]
+ * @return array<string, array<string, string>>
* @since 11.0.0
*/
public function getRichMessageParameters(): array;
@@ -227,8 +214,9 @@ interface IEvent {
* @param int $objectId
* @param string $objectName
* @return IEvent
- * @throws \InvalidArgumentException if the object is invalid
+ * @throws InvalidValueException if the object is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setObject(string $objectType, int $objectId, string $objectName = ''): self;
@@ -237,8 +225,9 @@ interface IEvent {
*
* @param string $link
* @return IEvent
- * @throws \InvalidArgumentException if the link is invalid
+ * @throws InvalidValueException if the link is invalid
* @since 8.2.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setLink(string $link): self;
@@ -321,14 +310,23 @@ interface IEvent {
public function getLink(): string;
/**
+ * Set the absolute url for the icon (should be colored black or not have a color)
+ *
+ * It's automatically color inverted by clients when needed
+ *
* @param string $icon
* @return $this
- * @throws \InvalidArgumentException if the icon is invalid
+ * @throws InvalidValueException if the icon is invalid
* @since 11.0.0
+ * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
*/
public function setIcon(string $icon): self;
/**
+ * Get the absolute url for the icon (should be colored black or not have a color)
+ *
+ * It's automatically color inverted by clients when needed
+ *
* @return string
* @since 11.0.0
*/
@@ -360,7 +358,7 @@ interface IEvent {
public function isValidParsed(): bool;
/**
- * Set whether or not a notification should be automatically generated for this activity.
+ * Set whether a notification should be automatically generated for this activity.
*
* Set this to `false` if the app already generates a notification for the event.
*
@@ -371,7 +369,7 @@ interface IEvent {
public function setGenerateNotification(bool $generate): self;
/**
- * whether or not a notification should be automatically generated for this activity.
+ * Whether a notification should be automatically generated for this activity.
*
* @return bool
* @since 20.0.0
diff --git a/lib/public/Activity/IEventMerger.php b/lib/public/Activity/IEventMerger.php
index a093a52744c..5d0f691f2d4 100644
--- a/lib/public/Activity/IEventMerger.php
+++ b/lib/public/Activity/IEventMerger.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Activity;
@@ -28,7 +12,6 @@ namespace OCP\Activity;
* @since 11.0
*/
interface IEventMerger {
-
/**
* Combines two events when possible to have grouping:
*
@@ -58,5 +41,5 @@ interface IEventMerger {
* @return IEvent
* @since 11.0
*/
- public function mergeEvents($mergeParameter, IEvent $event, IEvent $previousEvent = null);
+ public function mergeEvents($mergeParameter, IEvent $event, ?IEvent $previousEvent = null);
}
diff --git a/lib/public/Activity/IExtension.php b/lib/public/Activity/IExtension.php
index e02347f0373..c85d8ce5ed9 100644
--- a/lib/public/Activity/IExtension.php
+++ b/lib/public/Activity/IExtension.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCP\Activity;
@@ -31,13 +13,43 @@ namespace OCP\Activity;
* @since 8.0.0
*/
interface IExtension {
+ /**
+ * @since 8.0.0
+ */
public const METHOD_STREAM = 'stream';
+
+ /**
+ * @since 8.0.0
+ */
public const METHOD_MAIL = 'email';
+
+ /**
+ * @since 20.0.0
+ */
public const METHOD_NOTIFICATION = 'notification';
+ /**
+ * @since 8.0.0
+ */
public const PRIORITY_VERYLOW = 10;
+
+ /**
+ * @since 8.0.0
+ */
public const PRIORITY_LOW = 20;
+
+ /**
+ * @since 8.0.0
+ */
public const PRIORITY_MEDIUM = 30;
+
+ /**
+ * @since 8.0.0
+ */
public const PRIORITY_HIGH = 40;
+
+ /**
+ * @since 8.0.0
+ */
public const PRIORITY_VERYHIGH = 50;
}
diff --git a/lib/public/Activity/IFilter.php b/lib/public/Activity/IFilter.php
index 967a739726c..008de6f5bca 100644
--- a/lib/public/Activity/IFilter.php
+++ b/lib/public/Activity/IFilter.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Activity;
@@ -28,7 +12,6 @@ namespace OCP\Activity;
* @since 11.0.0
*/
interface IFilter {
-
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
@@ -43,8 +26,8 @@ interface IFilter {
/**
* @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The filters are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority();
diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php
index 9130c6b6b90..d638b8b2c6b 100644
--- a/lib/public/Activity/IManager.php
+++ b/lib/public/Activity/IManager.php
@@ -1,33 +1,17 @@
<?php
declare(strict_types=1);
-
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCP\Activity;
+use OCP\Activity\Exceptions\FilterNotFoundException;
+use OCP\Activity\Exceptions\IncompleteActivityException;
+use OCP\Activity\Exceptions\SettingNotFoundException;
+
/**
* Interface IManager
*
@@ -61,12 +45,27 @@ interface IManager {
* - setObject()
*
* @param IEvent $event
- * @throws \BadMethodCallException if required values have not been set
+ * @throws IncompleteActivityException if required values have not been set
* @since 8.2.0
+ * @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
*/
public function publish(IEvent $event): void;
/**
+ * Bulk publish an event for multiple users
+ * taking into account the app specific activity settings
+ *
+ * Make sure to call at least the following methods before sending an Event:
+ * - setApp()
+ * - setType()
+ *
+ * @param IEvent $event
+ * @throws IncompleteActivityException if required values have not been set
+ * @since 32.0.0
+ */
+ public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void;
+
+ /**
* In order to improve lazy loading a closure can be registered which will be called in case
* activity consumers are actually requested
*
@@ -92,8 +91,9 @@ interface IManager {
/**
* @param string $id
* @return IFilter
- * @throws \InvalidArgumentException when the filter was not found
+ * @throws FilterNotFoundException when the filter was not found
* @since 11.0.0
+ * @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
*/
public function getFilterById(string $id): IFilter;
@@ -124,8 +124,9 @@ interface IManager {
/**
* @param string $id
* @return ActivitySettings
- * @throws \InvalidArgumentException when the setting was not found
+ * @throws SettingNotFoundException when the setting was not found
* @since 11.0.0
+ * @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
*/
public function getSettingById(string $id): ActivitySettings;
@@ -158,10 +159,9 @@ interface IManager {
* Set the user we need to use
*
* @param string|null $currentUserId
- * @throws \UnexpectedValueException If the user is invalid
* @since 9.0.1
*/
- public function setCurrentUserId(string $currentUserId = null): void;
+ public function setCurrentUserId(?string $currentUserId = null): void;
/**
* Get the user we need to use
diff --git a/lib/public/Activity/IProvider.php b/lib/public/Activity/IProvider.php
index 657ffdeadbc..dec4e7ade64 100644
--- a/lib/public/Activity/IProvider.php
+++ b/lib/public/Activity/IProvider.php
@@ -1,27 +1,13 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Activity;
+use OCP\Activity\Exceptions\UnknownActivityException;
+
/**
* Interface IProvider
*
@@ -35,8 +21,11 @@ interface IProvider {
* To do so, simply use setChildEvent($previousEvent) after setting the
* combined subject on the current event.
* @return IEvent
- * @throws \InvalidArgumentException Should be thrown if your provider does not know this event
+ * @throws UnknownActivityException Should be thrown if your provider does not know this event
* @since 11.0.0
+ * @since 30.0.0 Providers should throw {@see UnknownActivityException} instead of \InvalidArgumentException
+ * when they did not handle the event. Throwing \InvalidArgumentException directly is deprecated and will
+ * be logged as an error in Nextcloud 39.
*/
- public function parse($language, IEvent $event, IEvent $previousEvent = null);
+ public function parse($language, IEvent $event, ?IEvent $previousEvent = null);
}
diff --git a/lib/public/Activity/ISetting.php b/lib/public/Activity/ISetting.php
index 53e01d42868..1304ab8c658 100644
--- a/lib/public/Activity/ISetting.php
+++ b/lib/public/Activity/ISetting.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Activity;
@@ -28,7 +12,6 @@ namespace OCP\Activity;
* @since 11.0.0
*/
interface ISetting {
-
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
@@ -43,8 +26,8 @@ interface ISetting {
/**
* @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The filters are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority();