ContactInteractedWithEvent.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  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\Contacts\Events;
  25. use OCP\EventDispatcher\Event;
  26. use OCP\IUser;
  27. /**
  28. * An event that allows apps to notify other components about an interaction
  29. * between two users. This can be used to build better recommendations and
  30. * suggestions in user interfaces.
  31. *
  32. * Emitters should add at least one identifier (uid, email, federated cloud ID)
  33. * of the recipient of the interaction.
  34. *
  35. * @since 19.0.0
  36. */
  37. class ContactInteractedWithEvent extends Event {
  38. /** @var IUser */
  39. private $actor;
  40. /** @var string|null */
  41. private $uid;
  42. /** @var string|null */
  43. private $email;
  44. /** @var string|null */
  45. private $federatedCloudId;
  46. /**
  47. * @param IUser $actor the user who started the interaction
  48. *
  49. * @since 19.0.0
  50. */
  51. public function __construct(IUser $actor) {
  52. parent::__construct();
  53. $this->actor = $actor;
  54. }
  55. /**
  56. * @return IUser
  57. * @since 19.0.0
  58. */
  59. public function getActor(): IUser {
  60. return $this->actor;
  61. }
  62. /**
  63. * @return string|null
  64. * @since 19.0.0
  65. */
  66. public function getUid(): ?string {
  67. return $this->uid;
  68. }
  69. /**
  70. * Set the uid of the person interacted with, if known
  71. *
  72. * @param string $uid
  73. *
  74. * @return self
  75. * @since 19.0.0
  76. */
  77. public function setUid(string $uid): self {
  78. $this->uid = $uid;
  79. return $this;
  80. }
  81. /**
  82. * @return string|null
  83. * @since 19.0.0
  84. */
  85. public function getEmail(): ?string {
  86. return $this->email;
  87. }
  88. /**
  89. * Set the email of the person interacted with, if known
  90. *
  91. * @param string $email
  92. *
  93. * @return self
  94. * @since 19.0.0
  95. */
  96. public function setEmail(string $email): self {
  97. $this->email = $email;
  98. return $this;
  99. }
  100. /**
  101. * @return string|null
  102. * @since 19.0.0
  103. */
  104. public function getFederatedCloudId(): ?string {
  105. return $this->federatedCloudId;
  106. }
  107. /**
  108. * Set the federated cloud of the person interacted with, if known
  109. *
  110. * @param string $federatedCloudId
  111. *
  112. * @return self
  113. * @since 19.0.0
  114. */
  115. public function setFederatedCloudId(string $federatedCloudId): self {
  116. $this->federatedCloudId = $federatedCloudId;
  117. return $this;
  118. }
  119. }