UserStatusProvider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\UserStatus\Connector;
  8. use OC\UserStatus\ISettableProvider;
  9. use OCA\UserStatus\Service\StatusService;
  10. use OCP\UserStatus\IProvider;
  11. class UserStatusProvider implements IProvider, ISettableProvider {
  12. /**
  13. * UserStatusProvider constructor.
  14. *
  15. * @param StatusService $service
  16. */
  17. public function __construct(
  18. private StatusService $service,
  19. ) {
  20. }
  21. /**
  22. * @inheritDoc
  23. */
  24. public function getUserStatuses(array $userIds): array {
  25. $statuses = $this->service->findByUserIds($userIds);
  26. $userStatuses = [];
  27. foreach ($statuses as $status) {
  28. $userStatuses[$status->getUserId()] = new UserStatus($status);
  29. }
  30. return $userStatuses;
  31. }
  32. public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup, ?string $customMessage = null): void {
  33. $this->service->setUserStatus($userId, $status, $messageId, $createBackup, $customMessage);
  34. }
  35. public function revertUserStatus(string $userId, string $messageId, string $status): void {
  36. $this->service->revertUserStatus($userId, $messageId);
  37. }
  38. public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void {
  39. $this->service->revertMultipleUserStatus($userIds, $messageId);
  40. }
  41. }