Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions lib/Dashboard/TalkWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Config;
use OCA\Talk\Exceptions\NotAllowedToUseTalkException;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\Comments\IComment;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IConditionalWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\IOptionWidget;
use OCP\Dashboard\Model\WidgetButton;
Expand All @@ -46,7 +46,9 @@
use OCP\IUserSession;
use OCP\Util;

class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidget {
class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidget, IConditionalWidget {
protected IUserSession $userSession;
protected Config $talkConfig;
protected IURLGenerator $url;
protected IL10N $l10n;
protected Manager $manager;
Expand All @@ -62,13 +64,8 @@ public function __construct(
ParticipantService $participantService,
MessageParser $messageParser
) {
$user = $userSession->getUser();
if ($user instanceof IUser && $talkConfig->isDisabledForUser($user)) {
// This is dirty and will log everytime a user opens the dashboard or requests the api,
// so we should look for a different solution in the server.
throw new NotAllowedToUseTalkException();
}

$this->userSession = $userSession;
$this->talkConfig = $talkConfig;
$this->url = $url;
$this->l10n = $l10n;
$this->manager = $manager;
Expand Down Expand Up @@ -104,6 +101,14 @@ public function getIconClass(): string {
return 'dashboard-talk-icon';
}

/**
* @inheritDoc
*/
public function isEnabled(): bool {
$user = $this->userSession->getUser();
return !($user instanceof IUser && $this->talkConfig->isDisabledForUser($user));
}

public function getWidgetOptions(): WidgetOptions {
return new WidgetOptions(true);
}
Expand Down
37 changes: 0 additions & 37 deletions lib/Exceptions/NotAllowedToUseTalkException.php

This file was deleted.