1
0

IEvent.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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.
  97. *
  98. * See https://github.com/nextcloud/server/issues/1706 for more information.
  99. *
  100. * @param string $subject
  101. * @return $this
  102. * @throws \InvalidArgumentException if the subject is invalid
  103. * @since 11.0.0
  104. */
  105. public function setParsedSubject(string $subject): self;
  106. /**
  107. * @return string
  108. * @since 11.0.0
  109. */
  110. public function getParsedSubject(): string;
  111. /**
  112. * Set a RichObjectString subject
  113. *
  114. * HTML is not allowed in the rich subject and will be escaped automatically
  115. * by the clients, but you can use the RichObjectString system provided by
  116. * the Nextcloud server to highlight important parameters.
  117. *
  118. * See https://github.com/nextcloud/server/issues/1706 for more information.
  119. *
  120. * @param string $subject
  121. * @param array $parameters
  122. * @return $this
  123. * @throws \InvalidArgumentException if the subject or parameters are invalid
  124. * @since 11.0.0
  125. */
  126. public function setRichSubject(string $subject, array $parameters = []): self;
  127. /**
  128. * @return string
  129. * @since 11.0.0
  130. */
  131. public function getRichSubject(): string;
  132. /**
  133. * @return array[]
  134. * @since 11.0.0
  135. */
  136. public function getRichSubjectParameters(): array;
  137. /**
  138. * Set the message of the activity
  139. *
  140. * @param string $message
  141. * @param array $parameters
  142. * @return IEvent
  143. * @throws \InvalidArgumentException if the message or parameters are invalid
  144. * @since 8.2.0
  145. */
  146. public function setMessage(string $message, array $parameters = []): self;
  147. /**
  148. * Set a parsed message
  149. *
  150. * HTML is not allowed in the parsed message and will be escaped
  151. * automatically by the clients. You can use the RichObjectString system
  152. * provided by the Nextcloud server to highlight important parameters via
  153. * the setRichMessage method.
  154. *
  155. * See https://github.com/nextcloud/server/issues/1706 for more information.
  156. *
  157. * @param string $message
  158. * @return $this
  159. * @throws \InvalidArgumentException if the message is invalid
  160. * @since 11.0.0
  161. */
  162. public function setParsedMessage(string $message): self;
  163. /**
  164. * @return string
  165. * @since 11.0.0
  166. */
  167. public function getParsedMessage(): string;
  168. /**
  169. * Set a RichObjectString message
  170. *
  171. * HTML is not allowed in the rich message and will be escaped automatically
  172. * by the clients, but you can use the RichObjectString system provided by
  173. * the Nextcloud server to highlight important parameters.
  174. *
  175. * See https://github.com/nextcloud/server/issues/1706 for more information.
  176. *
  177. * @param string $message
  178. * @param array $parameters
  179. * @return $this
  180. * @throws \InvalidArgumentException if the message or parameters are invalid
  181. * @since 11.0.0
  182. */
  183. public function setRichMessage(string $message, array $parameters = []): self;
  184. /**
  185. * @return string
  186. * @since 11.0.0
  187. */
  188. public function getRichMessage(): string;
  189. /**
  190. * @return array[]
  191. * @since 11.0.0
  192. */
  193. public function getRichMessageParameters(): array;
  194. /**
  195. * Set the object of the activity
  196. *
  197. * @param string $objectType
  198. * @param int $objectId
  199. * @param string $objectName
  200. * @return IEvent
  201. * @throws \InvalidArgumentException if the object is invalid
  202. * @since 8.2.0
  203. */
  204. public function setObject(string $objectType, int $objectId, string $objectName = ''): self;
  205. /**
  206. * Set the link of the activity
  207. *
  208. * @param string $link
  209. * @return IEvent
  210. * @throws \InvalidArgumentException if the link is invalid
  211. * @since 8.2.0
  212. */
  213. public function setLink(string $link): self;
  214. /**
  215. * @return string
  216. * @since 8.2.0
  217. */
  218. public function getApp(): string;
  219. /**
  220. * @return string
  221. * @since 8.2.0
  222. */
  223. public function getType(): string;
  224. /**
  225. * @return string
  226. * @since 8.2.0
  227. */
  228. public function getAffectedUser(): string;
  229. /**
  230. * @return string
  231. * @since 8.2.0
  232. */
  233. public function getAuthor(): string;
  234. /**
  235. * @return int
  236. * @since 8.2.0
  237. */
  238. public function getTimestamp(): int;
  239. /**
  240. * @return string
  241. * @since 8.2.0
  242. */
  243. public function getSubject(): string;
  244. /**
  245. * @return array
  246. * @since 8.2.0
  247. */
  248. public function getSubjectParameters(): array;
  249. /**
  250. * @return string
  251. * @since 8.2.0
  252. */
  253. public function getMessage(): string;
  254. /**
  255. * @return array
  256. * @since 8.2.0
  257. */
  258. public function getMessageParameters(): array;
  259. /**
  260. * @return string
  261. * @since 8.2.0
  262. */
  263. public function getObjectType(): string;
  264. /**
  265. * @return int
  266. * @since 8.2.0
  267. */
  268. public function getObjectId(): int;
  269. /**
  270. * @return string
  271. * @since 8.2.0
  272. */
  273. public function getObjectName(): string;
  274. /**
  275. * @return string
  276. * @since 8.2.0
  277. */
  278. public function getLink(): string;
  279. /**
  280. * @param string $icon
  281. * @return $this
  282. * @throws \InvalidArgumentException if the icon is invalid
  283. * @since 11.0.0
  284. */
  285. public function setIcon(string $icon): self;
  286. /**
  287. * @return string
  288. * @since 11.0.0
  289. */
  290. public function getIcon(): string;
  291. /**
  292. * @param IEvent $child
  293. * @return $this
  294. * @since 11.0.0 - Since 15.0.0 returns $this
  295. */
  296. public function setChildEvent(IEvent $child): self;
  297. /**
  298. * @return IEvent|null
  299. * @since 11.0.0
  300. */
  301. public function getChildEvent();
  302. /**
  303. * @return bool
  304. * @since 11.0.0
  305. */
  306. public function isValid(): bool;
  307. /**
  308. * @return bool
  309. * @since 11.0.0
  310. */
  311. public function isValidParsed(): bool;
  312. /**
  313. * Set whether or not a notification should be automatically generated for this activity.
  314. *
  315. * Set this to `false` if the app already generates a notification for the event.
  316. *
  317. * @param bool $generate
  318. * @return IEvent
  319. * @since 20.0.0
  320. */
  321. public function setGenerateNotification(bool $generate): self;
  322. /**
  323. * whether or not a notification should be automatically generated for this activity.
  324. *
  325. * @return bool
  326. * @since 20.0.0
  327. */
  328. public function getGenerateNotification(): bool;
  329. }