IManager.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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\UserStatus;
  25. /**
  26. * This interface allows to manage the user status.
  27. *
  28. * This interface must not be implemented in your application but
  29. * instead should be used as a service and injected in your code with
  30. * dependency injection.
  31. *
  32. * @since 20.0.0
  33. */
  34. interface IManager {
  35. /**
  36. * Gets the statuses for all users in $users
  37. *
  38. * @param string[] $userIds
  39. * @return array<string, IUserStatus> array key being the userid, users without a status will not be in the returned array
  40. * @since 20.0.0
  41. */
  42. public function getUserStatuses(array $userIds): array;
  43. /**
  44. * Set a new status for the selected user.
  45. *
  46. * @param string $userId The user for which we want to update the status.
  47. * @param string $messageId The id of the predefined message.
  48. * @param string $status The status to assign
  49. * @param bool $createBackup If true, this will store the old status so that it is possible to revert it later (e.g. after a call).
  50. * @since 23.0.0
  51. */
  52. public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup = false): void;
  53. /**
  54. * Revert an automatically set user status. For example after leaving a call,
  55. * change back to the previously set status.
  56. *
  57. * @param string $userId The user for which we want to update the status.
  58. * @param string $messageId The expected current messageId. If the user has already updated their status, this method does nothing.
  59. * @param string $status The expected current status. If the user has already updated their status, this method does nothing.
  60. * @since 23.0.0
  61. */
  62. public function revertUserStatus(string $userId, string $messageId, string $status): void;
  63. /**
  64. * Revert an automatically set user status. For example after leaving a call,
  65. * change back to the previously set status.
  66. *
  67. * @param string[] $userIds The user for which we want to update the status.
  68. * @param string $messageId The expected current messageId. If the user has already updated their status, this method does nothing.
  69. * @param string $status The expected current status. If the user has already updated their status, this method does nothing.
  70. * @since 23.0.0
  71. */
  72. public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void;
  73. }