1
0

UserLiveStatusEvent.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Georg Ehrke
  5. *
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\User\Events;
  25. use OCP\EventDispatcher\Event;
  26. use OCP\IUser;
  27. use OCP\UserStatus\IUserStatus;
  28. /**
  29. * @since 20.0.0
  30. */
  31. class UserLiveStatusEvent extends Event {
  32. /**
  33. * @var string
  34. * @since 20.0.0
  35. */
  36. public const STATUS_ONLINE = 'online';
  37. /**
  38. * @var string
  39. * @since 20.0.0
  40. */
  41. public const STATUS_AWAY = 'away';
  42. /**
  43. * @var string
  44. * @since 20.0.0
  45. */
  46. public const STATUS_OFFLINE = 'offline';
  47. private IUser $user;
  48. private string $status;
  49. private int $timestamp;
  50. private ?IUserStatus $userStatus = null;
  51. /**
  52. * @since 20.0.0
  53. */
  54. public function __construct(IUser $user,
  55. string $status,
  56. int $timestamp) {
  57. parent::__construct();
  58. $this->user = $user;
  59. $this->status = $status;
  60. $this->timestamp = $timestamp;
  61. }
  62. /**
  63. * @return IUser
  64. * @since 20.0.0
  65. */
  66. public function getUser(): IUser {
  67. return $this->user;
  68. }
  69. /**
  70. * @return string
  71. * @since 20.0.0
  72. */
  73. public function getStatus(): string {
  74. return $this->status;
  75. }
  76. /**
  77. * @return int
  78. * @since 20.0.0
  79. */
  80. public function getTimestamp(): int {
  81. return $this->timestamp;
  82. }
  83. /**
  84. * Get the user status that might be available after processing the event
  85. * @since 24.0.0
  86. */
  87. public function getUserStatus(): ?IUserStatus {
  88. return $this->userStatus;
  89. }
  90. /**
  91. * @since 24.0.0
  92. */
  93. public function setUserStatus(IUserStatus $userStatus) {
  94. $this->userStatus = $userStatus;
  95. }
  96. }