ContactInteractedWithEvent.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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\Contacts\Events;
  8. use OCP\EventDispatcher\Event;
  9. use OCP\IUser;
  10. /**
  11. * An event that allows apps to notify other components about an interaction
  12. * between two users. This can be used to build better recommendations and
  13. * suggestions in user interfaces.
  14. *
  15. * Emitters should add at least one identifier (uid, email, federated cloud ID)
  16. * of the recipient of the interaction.
  17. *
  18. * @since 19.0.0
  19. */
  20. class ContactInteractedWithEvent extends Event {
  21. /** @var IUser */
  22. private $actor;
  23. /** @var string|null */
  24. private $uid;
  25. /** @var string|null */
  26. private $email;
  27. /** @var string|null */
  28. private $federatedCloudId;
  29. /**
  30. * @param IUser $actor the user who started the interaction
  31. *
  32. * @since 19.0.0
  33. */
  34. public function __construct(IUser $actor) {
  35. parent::__construct();
  36. $this->actor = $actor;
  37. }
  38. /**
  39. * @return IUser
  40. * @since 19.0.0
  41. */
  42. public function getActor(): IUser {
  43. return $this->actor;
  44. }
  45. /**
  46. * @return string|null
  47. * @since 19.0.0
  48. */
  49. public function getUid(): ?string {
  50. return $this->uid;
  51. }
  52. /**
  53. * Set the uid of the person interacted with, if known
  54. *
  55. * @param string $uid
  56. *
  57. * @return self
  58. * @since 19.0.0
  59. */
  60. public function setUid(string $uid): self {
  61. $this->uid = $uid;
  62. return $this;
  63. }
  64. /**
  65. * @return string|null
  66. * @since 19.0.0
  67. */
  68. public function getEmail(): ?string {
  69. return $this->email;
  70. }
  71. /**
  72. * Set the email of the person interacted with, if known
  73. *
  74. * @param string $email
  75. *
  76. * @return self
  77. * @since 19.0.0
  78. */
  79. public function setEmail(string $email): self {
  80. $this->email = $email;
  81. return $this;
  82. }
  83. /**
  84. * @return string|null
  85. * @since 19.0.0
  86. */
  87. public function getFederatedCloudId(): ?string {
  88. return $this->federatedCloudId;
  89. }
  90. /**
  91. * Set the federated cloud of the person interacted with, if known
  92. *
  93. * @param string $federatedCloudId
  94. *
  95. * @return self
  96. * @since 19.0.0
  97. */
  98. public function setFederatedCloudId(string $federatedCloudId): self {
  99. $this->federatedCloudId = $federatedCloudId;
  100. return $this;
  101. }
  102. }