IEvent.php 9.0 KB

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