1
0

UserLiveStatusEvent.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 OCP\User\Events;
  8. use OCP\EventDispatcher\Event;
  9. use OCP\IUser;
  10. use OCP\UserStatus\IUserStatus;
  11. /**
  12. * @since 20.0.0
  13. */
  14. class UserLiveStatusEvent extends Event {
  15. /**
  16. * @var string
  17. * @since 20.0.0
  18. */
  19. public const STATUS_ONLINE = 'online';
  20. /**
  21. * @var string
  22. * @since 20.0.0
  23. */
  24. public const STATUS_AWAY = 'away';
  25. /**
  26. * @var string
  27. * @since 20.0.0
  28. */
  29. public const STATUS_OFFLINE = 'offline';
  30. private IUser $user;
  31. private string $status;
  32. private int $timestamp;
  33. private ?IUserStatus $userStatus = null;
  34. /**
  35. * @since 20.0.0
  36. */
  37. public function __construct(IUser $user,
  38. string $status,
  39. int $timestamp) {
  40. parent::__construct();
  41. $this->user = $user;
  42. $this->status = $status;
  43. $this->timestamp = $timestamp;
  44. }
  45. /**
  46. * @return IUser
  47. * @since 20.0.0
  48. */
  49. public function getUser(): IUser {
  50. return $this->user;
  51. }
  52. /**
  53. * @return string
  54. * @since 20.0.0
  55. */
  56. public function getStatus(): string {
  57. return $this->status;
  58. }
  59. /**
  60. * @return int
  61. * @since 20.0.0
  62. */
  63. public function getTimestamp(): int {
  64. return $this->timestamp;
  65. }
  66. /**
  67. * Get the user status that might be available after processing the event
  68. * @since 24.0.0
  69. */
  70. public function getUserStatus(): ?IUserStatus {
  71. return $this->userStatus;
  72. }
  73. /**
  74. * @since 24.0.0
  75. */
  76. public function setUserStatus(IUserStatus $userStatus) {
  77. $this->userStatus = $userStatus;
  78. }
  79. }