diff options
Diffstat (limited to 'lib/public/Talk')
-rw-r--r-- | lib/public/Talk/Exceptions/NoBackendException.php | 20 | ||||
-rw-r--r-- | lib/public/Talk/IBroker.php | 68 | ||||
-rw-r--r-- | lib/public/Talk/IConversation.php | 31 | ||||
-rw-r--r-- | lib/public/Talk/IConversationOptions.php | 33 | ||||
-rw-r--r-- | lib/public/Talk/ITalkBackend.php | 45 |
5 files changed, 197 insertions, 0 deletions
diff --git a/lib/public/Talk/Exceptions/NoBackendException.php b/lib/public/Talk/Exceptions/NoBackendException.php new file mode 100644 index 00000000000..4e7a8d50769 --- /dev/null +++ b/lib/public/Talk/Exceptions/NoBackendException.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Talk\Exceptions; + +use RuntimeException; + +/** + * Thrown when the Talk API is accessed but there is no registered backend + * + * @since 24.0.0 + */ +final class NoBackendException extends RuntimeException { +} diff --git a/lib/public/Talk/IBroker.php b/lib/public/Talk/IBroker.php new file mode 100644 index 00000000000..cfea4af6873 --- /dev/null +++ b/lib/public/Talk/IBroker.php @@ -0,0 +1,68 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Talk; + +use OCP\IUser; +use OCP\Talk\Exceptions\NoBackendException; + +/** + * Abstraction over the optional Talk backend + * + * http://software-pattern.org/Broker + * + * @since 24.0.0 + */ +interface IBroker { + /** + * Check if the Talk backend is available + * + * @return bool + * @since 24.0.0 + */ + public function hasBackend(): bool; + + /** + * Create a new instance of the objects object for specifics of a new conversation + * + * @return IConversationOptions + * @throws NoBackendException when Talk is not available + * @since 24.0.0 + */ + public function newConversationOptions(): IConversationOptions; + + /** + * Create a new conversation + * + * The conversation is private by default. Use the options parameter to make + * it public. + * + * @param string $name + * @param IUser[] $moderators + * @param IConversationOptions|null $options optional configuration for the conversation + * + * @return IConversation + * @throws NoBackendException when Talk is not available + * @since 24.0.0 + */ + public function createConversation(string $name, + array $moderators, + ?IConversationOptions $options = null): IConversation; + + /** + * Delete a conversation by id + * + * @param string $id conversation id + * + * @return void + * @throws NoBackendException when Talk is not available + * @since 26.0.0 + */ + public function deleteConversation(string $id): void; +} diff --git a/lib/public/Talk/IConversation.php b/lib/public/Talk/IConversation.php new file mode 100644 index 00000000000..377f76d8809 --- /dev/null +++ b/lib/public/Talk/IConversation.php @@ -0,0 +1,31 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Talk; + +/** + * @since 24.0.0 + */ +interface IConversation { + /** + * Get the unique token that identifies this conversation + * + * @return string + * @since 26.0.0 + */ + public function getId(): string; + + /** + * Get the absolute URL to this conversation + * + * @return string + * @since 24.0.0 + */ + public function getAbsoluteUrl(): string; +} diff --git a/lib/public/Talk/IConversationOptions.php b/lib/public/Talk/IConversationOptions.php new file mode 100644 index 00000000000..9433bad9893 --- /dev/null +++ b/lib/public/Talk/IConversationOptions.php @@ -0,0 +1,33 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Talk; + +/** + * @since 24.0.0 + */ +interface IConversationOptions { + /** + * Will the conversation be public? + * + * @return bool + * @since 24.0.0 + */ + public function isPublic(): bool; + + /** + * Make the new conversation public + * + * @param bool $isPublic + * + * @return $this + * @since 24.0.0 + */ + public function setPublic(bool $isPublic = true): self; +} diff --git a/lib/public/Talk/ITalkBackend.php b/lib/public/Talk/ITalkBackend.php new file mode 100644 index 00000000000..66dbd3c485d --- /dev/null +++ b/lib/public/Talk/ITalkBackend.php @@ -0,0 +1,45 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Talk; + +use OCP\IUser; + +/** + * Interface for the Talk app to implement + * + * Other apps must not implement nor use this interface in any way. Use the + * broker instead + * + * @see IBroker + * @since 24.0.0 + */ +interface ITalkBackend { + /** + * @param string $name + * @param IUser[] $moderators + * @param IConversationOptions $options configuration for the conversation + * + * @return IConversation + * @since 24.0.0 + */ + public function createConversation(string $name, + array $moderators, + IConversationOptions $options): IConversation; + + /** + * Delete a conversation by id + * + * @param string $id conversation id + * + * @return void + * @since 26.0.0 + */ + public function deleteConversation(string $id): void; +} |