From 950a3f8d370330cdd9f1be0c4c5d4b1f1423dbed Mon Sep 17 00:00:00 2001 From: Hamza Date: Sun, 26 Apr 2026 16:58:21 +0200 Subject: [PATCH] feat(ocp): expose whether talk is enabled for user Signed-off-by: Hamza --- lib/private/Talk/Broker.php | 16 ++++++++++++++++ lib/public/Talk/IBroker.php | 24 ++++++++++++++++++++++++ lib/public/Talk/ITalkBackend.php | 24 ++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/lib/private/Talk/Broker.php b/lib/private/Talk/Broker.php index eaf5fad96c6..9bae84ea684 100644 --- a/lib/private/Talk/Broker.php +++ b/lib/private/Talk/Broker.php @@ -91,4 +91,20 @@ class Broker implements IBroker { $this->backend->deleteConversation($id); } + + public function isDisabledForUser(): bool { + if (!$this->hasBackend()) { + return true; + } + + return $this->backend->isDisabledForUser(); + } + + public function isNotAllowedToCreateConversations(): bool { + if (!$this->hasBackend()) { + return true; + } + + return $this->backend->isNotAllowedToCreateConversations(); + } } diff --git a/lib/public/Talk/IBroker.php b/lib/public/Talk/IBroker.php index cfea4af6873..be866ea5f4d 100644 --- a/lib/public/Talk/IBroker.php +++ b/lib/public/Talk/IBroker.php @@ -65,4 +65,28 @@ interface IBroker { * @since 26.0.0 */ public function deleteConversation(string $id): void; + + /** + * Check if the logged in user is not allowed to create conversations, + * respecting the per-group restrictions configured in Talk admin settings + * (allowed_groups). + * + * Returns false when Talk is not available at all. + * + * @return bool + * @since 34.0.0 + */ + public function isNotAllowedToCreateConversations(): bool; + + /** + * Check if Talk is disabled for the logged in user, respecting the + * per-group restriction configured in Talk admin settings + * (start_conversations). + * + * Returns false when Talk is not available at all. + * + * @return bool + * @since 34.0.0 + */ + public function isDisabledForUser(): bool; } diff --git a/lib/public/Talk/ITalkBackend.php b/lib/public/Talk/ITalkBackend.php index 66dbd3c485d..e8faa378223 100644 --- a/lib/public/Talk/ITalkBackend.php +++ b/lib/public/Talk/ITalkBackend.php @@ -42,4 +42,28 @@ interface ITalkBackend { * @since 26.0.0 */ public function deleteConversation(string $id): void; + + /** + * Check if the logged in user is not allowed to create conversations, + * respecting the per-group restrictions configured in Talk admin settings + * (allowed_groups). + * + * Returns false when Talk is not available at all. + * + * @return bool + * @since 34.0.0 + */ + public function isNotAllowedToCreateConversations(): bool; + + /** + * Check if Talk is disabled for the logged in user, respecting the + * per-group restriction configured in Talk admin settings + * (start_conversations). + * + * Returns false when Talk is not available at all. + * + * @return bool + * @since 34.0.0 + */ + public function isDisabledForUser(): bool; }