aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Activity')
-rw-r--r--lib/public/Activity/ActivitySettings.php98
-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.php26
-rw-r--r--lib/public/Activity/IEvent.php378
-rw-r--r--lib/public/Activity/IEventMerger.php45
-rw-r--r--lib/public/Activity/IExtension.php55
-rw-r--r--lib/public/Activity/IFilter.php53
-rw-r--r--lib/public/Activity/IManager.php176
-rw-r--r--lib/public/Activity/IProvider.php31
-rw-r--r--lib/public/Activity/ISetting.php58
15 files changed, 1080 insertions, 0 deletions
diff --git a/lib/public/Activity/ActivitySettings.php b/lib/public/Activity/ActivitySettings.php
new file mode 100644
index 00000000000..fa187164e19
--- /dev/null
+++ b/lib/public/Activity/ActivitySettings.php
@@ -0,0 +1,98 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Activity;
+
+/**
+ * @since 20.0.0
+ */
+abstract class ActivitySettings implements ISetting {
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 20.0.0
+ */
+ abstract public function getIdentifier();
+
+ /**
+ * @return string A translated string
+ * @since 20.0.0
+ */
+ abstract public function getName();
+
+ /**
+ * @return string Lowercase a-z and underscore only group identifier
+ * @since 20.0.0
+ */
+ abstract public function getGroupIdentifier();
+
+ /**
+ * @return string A translated string for the settings group
+ * @since 20.0.0
+ */
+ abstract public function getGroupName();
+
+ /**
+ * @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.
+ * @since 20.0.0
+ */
+ abstract public function getPriority();
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 20.0.0
+ */
+ public function canChangeMail() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the notification
+ * @since 20.0.0
+ */
+ public function canChangeNotification() {
+ return true;
+ }
+
+ /**
+ * @return bool Whether or not an activity email should be send by default
+ * @since 20.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+
+ /**
+ * @return bool Whether or not an activity notification should be send by default
+ * @since 20.0.0
+ */
+ public function isDefaultEnabledNotification() {
+ return $this->isDefaultEnabledMail() && !$this->canChangeMail();
+ }
+
+ /**
+ * Left in for backwards compatibility
+ *
+ * @return bool
+ * @since 20.0.0
+ */
+ public function canChangeStream() {
+ return false;
+ }
+
+ /**
+ * Left in for backwards compatibility
+ *
+ * @return bool
+ * @since 20.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return true;
+ }
+}
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
new file mode 100644
index 00000000000..4cf35ea5a44
--- /dev/null
+++ b/lib/public/Activity/IConsumer.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * 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 Nextcloud classes
+
+namespace OCP\Activity;
+
+/**
+ * Interface IConsumer
+ *
+ * @since 6.0.0
+ */
+interface IConsumer {
+ /**
+ * @param IEvent $event
+ * @return null
+ * @since 6.0.0
+ * @since 8.2.0 Replaced the parameters with an IEvent object
+ */
+ public function receive(IEvent $event);
+}
diff --git a/lib/public/Activity/IEvent.php b/lib/public/Activity/IEvent.php
new file mode 100644
index 00000000000..6014b75123c
--- /dev/null
+++ b/lib/public/Activity/IEvent.php
@@ -0,0 +1,378 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * 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 Nextcloud classes
+
+namespace OCP\Activity;
+
+use OCP\Activity\Exceptions\InvalidValueException;
+
+/**
+ * Interface IEvent
+ *
+ * @since 8.2.0
+ */
+interface IEvent {
+ /**
+ * Set the app of the activity
+ *
+ * @param string $app
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set the type of the activity
+ *
+ * @param string $type
+ * @return IEvent
+ * @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 $affectedUser
+ * @return IEvent
+ * @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 $affectedUser): self;
+
+ /**
+ * Set the author of the activity
+ *
+ * @param string $author
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set the author of the activity
+ *
+ * @param int $timestamp
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set the subject of the activity
+ *
+ * @param string $subject
+ * @param array $parameters
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set a parsed subject
+ *
+ * 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.
+ *
+ * See https://github.com/nextcloud/server/issues/1706 for more information.
+ *
+ * @param string $subject
+ * @return $this
+ * @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;
+
+ /**
+ * @return string
+ * @since 11.0.0
+ */
+ public function getParsedSubject(): string;
+
+ /**
+ * Set a RichObjectString subject
+ *
+ * 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.
+ *
+ * See https://github.com/nextcloud/server/issues/1706 for more information.
+ *
+ * @param string $subject
+ * @param array<string, array<string, string>> $parameters
+ * @return $this
+ * @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;
+
+ /**
+ * @return string
+ * @since 11.0.0
+ */
+ public function getRichSubject(): string;
+
+ /**
+ * @return array<string, array<string, string>>
+ * @since 11.0.0
+ */
+ public function getRichSubjectParameters(): array;
+
+ /**
+ * Set the message of the activity
+ *
+ * @param string $message
+ * @param array $parameters
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set a parsed message
+ *
+ * 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.
+ *
+ * See https://github.com/nextcloud/server/issues/1706 for more information.
+ *
+ * @param string $message
+ * @return $this
+ * @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;
+
+ /**
+ * @return string
+ * @since 11.0.0
+ */
+ public function getParsedMessage(): string;
+
+ /**
+ * Set a RichObjectString message
+ *
+ * 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.
+ *
+ * See https://github.com/nextcloud/server/issues/1706 for more information.
+ *
+ * @param string $message
+ * @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;
+
+ /**
+ * @return string
+ * @since 11.0.0
+ */
+ public function getRichMessage(): string;
+
+ /**
+ * @return array<string, array<string, string>>
+ * @since 11.0.0
+ */
+ public function getRichMessageParameters(): array;
+
+ /**
+ * Set the object of the activity
+ *
+ * @param string $objectType
+ * @param int $objectId
+ * @param string $objectName
+ * @return IEvent
+ * @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;
+
+ /**
+ * Set the link of the activity
+ *
+ * @param string $link
+ * @return IEvent
+ * @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;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getApp(): string;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getType(): string;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getAffectedUser(): string;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getAuthor(): string;
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getTimestamp(): int;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getSubject(): string;
+
+ /**
+ * @return array
+ * @since 8.2.0
+ */
+ public function getSubjectParameters(): array;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getMessage(): string;
+
+ /**
+ * @return array
+ * @since 8.2.0
+ */
+ public function getMessageParameters(): array;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectType(): string;
+
+ /**
+ * @return int
+ * @since 8.2.0
+ */
+ public function getObjectId(): int;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ public function getObjectName(): string;
+
+ /**
+ * @return string
+ * @since 8.2.0
+ */
+ 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 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
+ */
+ public function getIcon(): string;
+
+ /**
+ * @param IEvent $child
+ * @return $this
+ * @since 11.0.0 - Since 15.0.0 returns $this
+ */
+ public function setChildEvent(IEvent $child): self;
+
+ /**
+ * @return IEvent|null
+ * @since 11.0.0
+ */
+ public function getChildEvent();
+
+ /**
+ * @return bool
+ * @since 11.0.0
+ */
+ public function isValid(): bool;
+
+ /**
+ * @return bool
+ * @since 11.0.0
+ */
+ public function isValidParsed(): bool;
+
+ /**
+ * 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.
+ *
+ * @param bool $generate
+ * @return IEvent
+ * @since 20.0.0
+ */
+ public function setGenerateNotification(bool $generate): self;
+
+ /**
+ * Whether a notification should be automatically generated for this activity.
+ *
+ * @return bool
+ * @since 20.0.0
+ */
+ public function getGenerateNotification(): bool;
+}
diff --git a/lib/public/Activity/IEventMerger.php b/lib/public/Activity/IEventMerger.php
new file mode 100644
index 00000000000..5d0f691f2d4
--- /dev/null
+++ b/lib/public/Activity/IEventMerger.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Activity;
+
+/**
+ * Interface EventMerger
+ *
+ * @since 11.0
+ */
+interface IEventMerger {
+ /**
+ * Combines two events when possible to have grouping:
+ *
+ * Example1: Two events with subject '{user} created {file}' and
+ * $mergeParameter file with different file and same user will be merged
+ * to '{user} created {file1} and {file2}' and the childEvent on the return
+ * will be set, if the events have been merged.
+ *
+ * Example2: Two events with subject '{user} created {file}' and
+ * $mergeParameter file with same file and same user will be merged to
+ * '{user} created {file1}' and the childEvent on the return will be set, if
+ * the events have been merged.
+ *
+ * The following requirements have to be met, in order to be merged:
+ * - Both events need to have the same `getApp()`
+ * - Both events must not have a message `getMessage()`
+ * - Both events need to have the same subject `getSubject()`
+ * - Both events need to have the same object type `getObjectType()`
+ * - The time difference between both events must not be bigger then 3 hours
+ * - Only up to 5 events can be merged.
+ * - All parameters apart from such starting with $mergeParameter must be
+ * the same for both events.
+ *
+ * @param string $mergeParameter
+ * @param IEvent $event
+ * @param IEvent|null $previousEvent
+ * @return IEvent
+ * @since 11.0
+ */
+ public function mergeEvents($mergeParameter, IEvent $event, ?IEvent $previousEvent = null);
+}
diff --git a/lib/public/Activity/IExtension.php b/lib/public/Activity/IExtension.php
new file mode 100644
index 00000000000..c85d8ce5ed9
--- /dev/null
+++ b/lib/public/Activity/IExtension.php
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+namespace OCP\Activity;
+
+/**
+ * Interface IExtension
+ *
+ * @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
new file mode 100644
index 00000000000..008de6f5bca
--- /dev/null
+++ b/lib/public/Activity/IFilter.php
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Activity;
+
+/**
+ * Interface IFilter
+ *
+ * @since 11.0.0
+ */
+interface IFilter {
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier();
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName();
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority();
+
+ /**
+ * @return string Full URL to an icon, empty string when none is given
+ * @since 11.0.0
+ */
+ public function getIcon();
+
+ /**
+ * @param string[] $types
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function filterTypes(array $types);
+
+ /**
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function allowedApps();
+}
diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php
new file mode 100644
index 00000000000..d638b8b2c6b
--- /dev/null
+++ b/lib/public/Activity/IManager.php
@@ -0,0 +1,176 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * 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
+ *
+ * @since 6.0.0
+ */
+interface IManager {
+ /**
+ * Generates a new IEvent object
+ *
+ * Make sure to call at least the following methods before sending it to the
+ * app with via the publish() method:
+ * - setApp()
+ * - setType()
+ * - setAffectedUser()
+ * - setSubject()
+ * - setObject()
+ *
+ * @return IEvent
+ * @since 8.2.0
+ */
+ public function generateEvent(): IEvent;
+
+ /**
+ * Publish an event to the activity consumers
+ *
+ * Make sure to call at least the following methods before sending an Event:
+ * - setApp()
+ * - setType()
+ * - setAffectedUser()
+ * - setSubject()
+ * - setObject()
+ *
+ * @param IEvent $event
+ * @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
+ *
+ * $callable has to return an instance of \OCP\Activity\IConsumer
+ *
+ * @param \Closure $callable
+ * @since 6.0.0
+ */
+ public function registerConsumer(\Closure $callable): void;
+
+ /**
+ * @param string $filter Class must implement OCA\Activity\IFilter
+ * @since 11.0.0
+ */
+ public function registerFilter(string $filter): void;
+
+ /**
+ * @return IFilter[]
+ * @since 11.0.0
+ */
+ public function getFilters(): array;
+
+ /**
+ * @param string $id
+ * @return IFilter
+ * @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;
+
+ /**
+ * @param string $setting Class must implement OCA\Activity\ISetting
+ * @since 11.0.0
+ */
+ public function registerSetting(string $setting): void;
+
+ /**
+ * @return ActivitySettings[]
+ * @since 11.0.0
+ */
+ public function getSettings(): array;
+
+ /**
+ * @param string $provider Class must implement OCA\Activity\IProvider
+ * @since 11.0.0
+ */
+ public function registerProvider(string $provider): void;
+
+ /**
+ * @return IProvider[]
+ * @since 11.0.0
+ */
+ public function getProviders(): array;
+
+ /**
+ * @param string $id
+ * @return ActivitySettings
+ * @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;
+
+ /**
+ * @param string $type
+ * @param int $id
+ * @since 8.2.0
+ */
+ public function setFormattingObject(string $type, int $id): void;
+
+ /**
+ * @return bool
+ * @since 8.2.0
+ */
+ public function isFormattingFilteredObject(): bool;
+
+ /**
+ * @param bool $status Set to true, when parsing events should not use SVG icons
+ * @since 12.0.1
+ */
+ public function setRequirePNG(bool $status): void;
+
+ /**
+ * @return bool
+ * @since 12.0.1
+ */
+ public function getRequirePNG(): bool;
+
+ /**
+ * Set the user we need to use
+ *
+ * @param string|null $currentUserId
+ * @since 9.0.1
+ */
+ public function setCurrentUserId(?string $currentUserId = null): void;
+
+ /**
+ * Get the user we need to use
+ *
+ * Either the user is logged in, or we try to get it from the token
+ *
+ * @return string
+ * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
+ * @since 8.1.0
+ */
+ public function getCurrentUserId(): string;
+}
diff --git a/lib/public/Activity/IProvider.php b/lib/public/Activity/IProvider.php
new file mode 100644
index 00000000000..dec4e7ade64
--- /dev/null
+++ b/lib/public/Activity/IProvider.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * 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
+ *
+ * @since 11.0.0
+ */
+interface IProvider {
+ /**
+ * @param string $language The language which should be used for translating, e.g. "en"
+ * @param IEvent $event The current event which should be parsed
+ * @param IEvent|null $previousEvent A potential previous event which you can combine with the current one.
+ * To do so, simply use setChildEvent($previousEvent) after setting the
+ * combined subject on the current event.
+ * @return IEvent
+ * @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);
+}
diff --git a/lib/public/Activity/ISetting.php b/lib/public/Activity/ISetting.php
new file mode 100644
index 00000000000..1304ab8c658
--- /dev/null
+++ b/lib/public/Activity/ISetting.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Activity;
+
+/**
+ * Interface ISetting
+ *
+ * @since 11.0.0
+ */
+interface ISetting {
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier();
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName();
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority();
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream();
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream();
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail();
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail();
+}