IEvent.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. // use OCP namespace for all classes that are considered public.
  9. // This means that they should be used by apps instead of the internal Nextcloud classes
  10. namespace OCP\Activity;
  11. use OCP\Activity\Exceptions\InvalidValueException;
  12. /**
  13. * Interface IEvent
  14. *
  15. * @since 8.2.0
  16. */
  17. interface IEvent {
  18. /**
  19. * Set the app of the activity
  20. *
  21. * @param string $app
  22. * @return IEvent
  23. * @throws InvalidValueException if the app id is invalid
  24. * @since 8.2.0
  25. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  26. */
  27. public function setApp(string $app): self;
  28. /**
  29. * Set the type of the activity
  30. *
  31. * @param string $type
  32. * @return IEvent
  33. * @throws InvalidValueException if the type is invalid
  34. * @since 8.2.0
  35. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  36. */
  37. public function setType(string $type): self;
  38. /**
  39. * Set the affected user of the activity
  40. *
  41. * @param string $affectedUser
  42. * @return IEvent
  43. * @throws InvalidValueException if the affected user is invalid
  44. * @since 8.2.0
  45. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  46. */
  47. public function setAffectedUser(string $affectedUser): self;
  48. /**
  49. * Set the author of the activity
  50. *
  51. * @param string $author
  52. * @return IEvent
  53. * @throws InvalidValueException if the author is invalid
  54. * @since 8.2.0
  55. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  56. */
  57. public function setAuthor(string $author): self;
  58. /**
  59. * Set the author of the activity
  60. *
  61. * @param int $timestamp
  62. * @return IEvent
  63. * @throws InvalidValueException if the timestamp is invalid
  64. * @since 8.2.0
  65. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  66. */
  67. public function setTimestamp(int $timestamp): self;
  68. /**
  69. * Set the subject of the activity
  70. *
  71. * @param string $subject
  72. * @param array $parameters
  73. * @return IEvent
  74. * @throws InvalidValueException if the subject or parameters are invalid
  75. * @since 8.2.0
  76. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  77. */
  78. public function setSubject(string $subject, array $parameters = []): self;
  79. /**
  80. * Set a parsed subject
  81. *
  82. * HTML is not allowed in the parsed subject and will be escaped
  83. * automatically by the clients. You can use the RichObjectString system
  84. * provided by the Nextcloud server to highlight important parameters via
  85. * the setRichSubject method.
  86. *
  87. * See https://github.com/nextcloud/server/issues/1706 for more information.
  88. *
  89. * @param string $subject
  90. * @return $this
  91. * @throws InvalidValueException if the subject is invalid
  92. * @since 11.0.0
  93. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  94. */
  95. public function setParsedSubject(string $subject): self;
  96. /**
  97. * @return string
  98. * @since 11.0.0
  99. */
  100. public function getParsedSubject(): string;
  101. /**
  102. * Set a RichObjectString subject
  103. *
  104. * HTML is not allowed in the rich subject and will be escaped automatically
  105. * by the clients, but you can use the RichObjectString system provided by
  106. * the Nextcloud server to highlight important parameters.
  107. *
  108. * See https://github.com/nextcloud/server/issues/1706 for more information.
  109. *
  110. * @param string $subject
  111. * @param array<string, array<string, string>> $parameters
  112. * @return $this
  113. * @throws InvalidValueException if the subject or parameters are invalid
  114. * @since 11.0.0
  115. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  116. */
  117. public function setRichSubject(string $subject, array $parameters = []): self;
  118. /**
  119. * @return string
  120. * @since 11.0.0
  121. */
  122. public function getRichSubject(): string;
  123. /**
  124. * @return array<string, array<string, string>>
  125. * @since 11.0.0
  126. */
  127. public function getRichSubjectParameters(): array;
  128. /**
  129. * Set the message of the activity
  130. *
  131. * @param string $message
  132. * @param array $parameters
  133. * @return IEvent
  134. * @throws InvalidValueException if the message or parameters are invalid
  135. * @since 8.2.0
  136. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  137. */
  138. public function setMessage(string $message, array $parameters = []): self;
  139. /**
  140. * Set a parsed message
  141. *
  142. * HTML is not allowed in the parsed message and will be escaped
  143. * automatically by the clients. You can use the RichObjectString system
  144. * provided by the Nextcloud server to highlight important parameters via
  145. * the setRichMessage method.
  146. *
  147. * See https://github.com/nextcloud/server/issues/1706 for more information.
  148. *
  149. * @param string $message
  150. * @return $this
  151. * @throws InvalidValueException if the message is invalid
  152. * @since 11.0.0
  153. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  154. */
  155. public function setParsedMessage(string $message): self;
  156. /**
  157. * @return string
  158. * @since 11.0.0
  159. */
  160. public function getParsedMessage(): string;
  161. /**
  162. * Set a RichObjectString message
  163. *
  164. * HTML is not allowed in the rich message and will be escaped automatically
  165. * by the clients, but you can use the RichObjectString system provided by
  166. * the Nextcloud server to highlight important parameters.
  167. *
  168. * See https://github.com/nextcloud/server/issues/1706 for more information.
  169. *
  170. * @param string $message
  171. * @param array<string, array<string, string>> $parameters
  172. * @return $this
  173. * @throws \InvalidArgumentException if the message or parameters are invalid
  174. * @since 11.0.0
  175. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  176. */
  177. public function setRichMessage(string $message, array $parameters = []): self;
  178. /**
  179. * @return string
  180. * @since 11.0.0
  181. */
  182. public function getRichMessage(): string;
  183. /**
  184. * @return array<string, array<string, string>>
  185. * @since 11.0.0
  186. */
  187. public function getRichMessageParameters(): array;
  188. /**
  189. * Set the object of the activity
  190. *
  191. * @param string $objectType
  192. * @param int $objectId
  193. * @param string $objectName
  194. * @return IEvent
  195. * @throws InvalidValueException if the object is invalid
  196. * @since 8.2.0
  197. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  198. */
  199. public function setObject(string $objectType, int $objectId, string $objectName = ''): self;
  200. /**
  201. * Set the link of the activity
  202. *
  203. * @param string $link
  204. * @return IEvent
  205. * @throws InvalidValueException if the link is invalid
  206. * @since 8.2.0
  207. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  208. */
  209. public function setLink(string $link): self;
  210. /**
  211. * @return string
  212. * @since 8.2.0
  213. */
  214. public function getApp(): string;
  215. /**
  216. * @return string
  217. * @since 8.2.0
  218. */
  219. public function getType(): string;
  220. /**
  221. * @return string
  222. * @since 8.2.0
  223. */
  224. public function getAffectedUser(): string;
  225. /**
  226. * @return string
  227. * @since 8.2.0
  228. */
  229. public function getAuthor(): string;
  230. /**
  231. * @return int
  232. * @since 8.2.0
  233. */
  234. public function getTimestamp(): int;
  235. /**
  236. * @return string
  237. * @since 8.2.0
  238. */
  239. public function getSubject(): string;
  240. /**
  241. * @return array
  242. * @since 8.2.0
  243. */
  244. public function getSubjectParameters(): array;
  245. /**
  246. * @return string
  247. * @since 8.2.0
  248. */
  249. public function getMessage(): string;
  250. /**
  251. * @return array
  252. * @since 8.2.0
  253. */
  254. public function getMessageParameters(): array;
  255. /**
  256. * @return string
  257. * @since 8.2.0
  258. */
  259. public function getObjectType(): string;
  260. /**
  261. * @return int
  262. * @since 8.2.0
  263. */
  264. public function getObjectId(): int;
  265. /**
  266. * @return string
  267. * @since 8.2.0
  268. */
  269. public function getObjectName(): string;
  270. /**
  271. * @return string
  272. * @since 8.2.0
  273. */
  274. public function getLink(): string;
  275. /**
  276. * @param string $icon
  277. * @return $this
  278. * @throws InvalidValueException if the icon is invalid
  279. * @since 11.0.0
  280. * @since 30.0.0 throws {@see InvalidValueException} instead of \InvalidArgumentException
  281. */
  282. public function setIcon(string $icon): self;
  283. /**
  284. * @return string
  285. * @since 11.0.0
  286. */
  287. public function getIcon(): string;
  288. /**
  289. * @param IEvent $child
  290. * @return $this
  291. * @since 11.0.0 - Since 15.0.0 returns $this
  292. */
  293. public function setChildEvent(IEvent $child): self;
  294. /**
  295. * @return IEvent|null
  296. * @since 11.0.0
  297. */
  298. public function getChildEvent();
  299. /**
  300. * @return bool
  301. * @since 11.0.0
  302. */
  303. public function isValid(): bool;
  304. /**
  305. * @return bool
  306. * @since 11.0.0
  307. */
  308. public function isValidParsed(): bool;
  309. /**
  310. * Set whether a notification should be automatically generated for this activity.
  311. *
  312. * Set this to `false` if the app already generates a notification for the event.
  313. *
  314. * @param bool $generate
  315. * @return IEvent
  316. * @since 20.0.0
  317. */
  318. public function setGenerateNotification(bool $generate): self;
  319. /**
  320. * Whether a notification should be automatically generated for this activity.
  321. *
  322. * @return bool
  323. * @since 20.0.0
  324. */
  325. public function getGenerateNotification(): bool;
  326. }