aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib/Connector
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_status/lib/Connector')
-rw-r--r--apps/user_status/lib/Connector/UserStatus.php49
-rw-r--r--apps/user_status/lib/Connector/UserStatusProvider.php43
2 files changed, 36 insertions, 56 deletions
diff --git a/apps/user_status/lib/Connector/UserStatus.php b/apps/user_status/lib/Connector/UserStatus.php
index d6b075dcd8e..04467a99e5e 100644
--- a/apps/user_status/lib/Connector/UserStatus.php
+++ b/apps/user_status/lib/Connector/UserStatus.php
@@ -3,30 +3,14 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Georg Ehrke
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @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: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserStatus\Connector;
use DateTimeImmutable;
-use OCP\UserStatus\IUserStatus;
use OCA\UserStatus\Db;
+use OCP\UserStatus\IUserStatus;
class UserStatus implements IUserStatus {
@@ -45,22 +29,19 @@ class UserStatus implements IUserStatus {
/** @var DateTimeImmutable|null */
private $clearAt;
- /**
- * UserStatus constructor.
- *
- * @param Db\UserStatus $status
- */
- public function __construct(Db\UserStatus $status) {
- $this->userId = $status->getUserId();
- $this->status = $status->getStatus();
- $this->message = $status->getCustomMessage();
- $this->icon = $status->getCustomIcon();
+ public function __construct(
+ private Db\UserStatus $internalStatus,
+ ) {
+ $this->userId = $this->internalStatus->getUserId();
+ $this->status = $this->internalStatus->getStatus();
+ $this->message = $this->internalStatus->getCustomMessage();
+ $this->icon = $this->internalStatus->getCustomIcon();
- if ($status->getStatus() === IUserStatus::INVISIBLE) {
+ if ($this->internalStatus->getStatus() === IUserStatus::INVISIBLE) {
$this->status = IUserStatus::OFFLINE;
}
- if ($status->getClearAt() !== null) {
- $this->clearAt = DateTimeImmutable::createFromFormat('U', (string)$status->getClearAt());
+ if ($this->internalStatus->getClearAt() !== null) {
+ $this->clearAt = DateTimeImmutable::createFromFormat('U', (string)$this->internalStatus->getClearAt());
}
}
@@ -98,4 +79,8 @@ class UserStatus implements IUserStatus {
public function getClearAt(): ?DateTimeImmutable {
return $this->clearAt;
}
+
+ public function getInternal(): Db\UserStatus {
+ return $this->internalStatus;
+ }
}
diff --git a/apps/user_status/lib/Connector/UserStatusProvider.php b/apps/user_status/lib/Connector/UserStatusProvider.php
index 1197d19c3ab..e84d69d1eb2 100644
--- a/apps/user_status/lib/Connector/UserStatusProvider.php
+++ b/apps/user_status/lib/Connector/UserStatusProvider.php
@@ -3,42 +3,25 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Georg Ehrke
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @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: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserStatus\Connector;
+use OC\UserStatus\ISettableProvider;
use OCA\UserStatus\Service\StatusService;
use OCP\UserStatus\IProvider;
-class UserStatusProvider implements IProvider {
-
- /** @var StatusService */
- private $service;
+class UserStatusProvider implements IProvider, ISettableProvider {
/**
* UserStatusProvider constructor.
*
* @param StatusService $service
*/
- public function __construct(StatusService $service) {
- $this->service = $service;
+ public function __construct(
+ private StatusService $service,
+ ) {
}
/**
@@ -54,4 +37,16 @@ class UserStatusProvider implements IProvider {
return $userStatuses;
}
+
+ public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup, ?string $customMessage = null): void {
+ $this->service->setUserStatus($userId, $status, $messageId, $createBackup, $customMessage);
+ }
+
+ public function revertUserStatus(string $userId, string $messageId, string $status): void {
+ $this->service->revertUserStatus($userId, $messageId);
+ }
+
+ public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
+ $this->service->revertMultipleUserStatus($userIds, $messageId);
+ }
}