You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

386 lines
9.1 KiB

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