Completed
Push — master ( c0595e...3999dc )
by
unknown
29:40
created
lib/public/Comments/ICommentsManager.php 1 patch
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -18,473 +18,473 @@
 block discarded – undo
18 18
  * @since 9.0.0
19 19
  */
20 20
 interface ICommentsManager {
21
-	/**
22
-	 * @const DELETED_USER type and id for a user that has been deleted
23
-	 * @see deleteReferencesOfActor
24
-	 * @since 9.0.0
25
-	 *
26
-	 * To be used as replacement for user type actors in deleteReferencesOfActor().
27
-	 *
28
-	 * User interfaces shall show "Deleted user" as display name, if needed.
29
-	 */
30
-	public const DELETED_USER = 'deleted_users';
31
-
32
-	/**
33
-	 * returns a comment instance
34
-	 *
35
-	 * @param string $id the ID of the comment
36
-	 * @return IComment
37
-	 * @throws NotFoundException
38
-	 * @since 9.0.0
39
-	 */
40
-	public function get($id);
41
-
42
-	/**
43
-	 * Returns the comment specified by the id and all it's child comments
44
-	 *
45
-	 * @param string $id
46
-	 * @param int $limit max number of entries to return, 0 returns all
47
-	 * @param int $offset the start entry
48
-	 * @return array{comment: IComment, replies: list<array{comment: IComment, replies: array<empty, empty>}>}
49
-	 * @since 9.0.0
50
-	 *
51
-	 * The return array looks like this
52
-	 * [
53
-	 * 	 'comment' => IComment, // root comment
54
-	 *   'replies' =>
55
-	 *   [
56
-	 *     0 =>
57
-	 *     [
58
-	 *       'comment' => IComment,
59
-	 *       'replies' =>
60
-	 *       [
61
-	 *         0 =>
62
-	 *         [
63
-	 *           'comment' => IComment,
64
-	 *           'replies' => [ … ]
65
-	 *         ],
66
-	 *         …
67
-	 *       ]
68
-	 *     ]
69
-	 *     1 =>
70
-	 *     [
71
-	 *       'comment' => IComment,
72
-	 *       'replies'=> [ … ]
73
-	 *     ],
74
-	 *     …
75
-	 *   ]
76
-	 * ]
77
-	 */
78
-	public function getTree($id, $limit = 0, $offset = 0);
79
-
80
-	/**
81
-	 * returns comments for a specific object (e.g. a file).
82
-	 *
83
-	 * The sort order is always newest to oldest.
84
-	 *
85
-	 * @param string $objectType the object type, e.g. 'files'
86
-	 * @param string $objectId the id of the object
87
-	 * @param int $limit optional, number of maximum comments to be returned. if
88
-	 *                   not specified, all comments are returned.
89
-	 * @param int $offset optional, starting point
90
-	 * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
91
-	 *                                     that may be returned
92
-	 * @return list<IComment>
93
-	 * @since 9.0.0
94
-	 */
95
-	public function getForObject(
96
-		$objectType,
97
-		$objectId,
98
-		$limit = 0,
99
-		$offset = 0,
100
-		?\DateTime $notOlderThan = null,
101
-	);
102
-
103
-	/**
104
-	 * @param string $objectType the object type, e.g. 'files'
105
-	 * @param string $objectId the id of the object
106
-	 * @param int $lastKnownCommentId the last known comment (will be used as offset)
107
-	 * @param string $sortDirection direction of the comments (`asc` or `desc`)
108
-	 * @param int $limit optional, number of maximum comments to be returned. if
109
-	 *                   set to 0, all comments are returned.
110
-	 * @param bool $includeLastKnown
111
-	 * @param string $topmostParentId Limit the comments to a list of replies and its original root comment
112
-	 * @return list<IComment>
113
-	 * @since 14.0.0
114
-	 * @deprecated 24.0.0 - Use getCommentsWithVerbForObjectSinceComment instead
115
-	 */
116
-	public function getForObjectSince(
117
-		string $objectType,
118
-		string $objectId,
119
-		int $lastKnownCommentId,
120
-		string $sortDirection = 'asc',
121
-		int $limit = 30,
122
-		bool $includeLastKnown = false,
123
-		string $topmostParentId = '',
124
-	): array;
125
-
126
-	/**
127
-	 * @param string $objectType the object type, e.g. 'files'
128
-	 * @param string $objectId the id of the object
129
-	 * @param string[] $verbs List of verbs to filter by
130
-	 * @param int $lastKnownCommentId the last known comment (will be used as offset)
131
-	 * @param string $sortDirection direction of the comments (`asc` or `desc`)
132
-	 * @param int $limit optional, number of maximum comments to be returned. if
133
-	 *                   set to 0, all comments are returned.
134
-	 * @param bool $includeLastKnown
135
-	 * @param string $topmostParentId Limit the comments to a list of replies and its original root comment
136
-	 * @return list<IComment>
137
-	 * @since 24.0.0
138
-	 */
139
-	public function getCommentsWithVerbForObjectSinceComment(
140
-		string $objectType,
141
-		string $objectId,
142
-		array $verbs,
143
-		int $lastKnownCommentId,
144
-		string $sortDirection = 'asc',
145
-		int $limit = 30,
146
-		bool $includeLastKnown = false,
147
-		string $topmostParentId = '',
148
-	): array;
149
-
150
-	/**
151
-	 * Search for comments with a given content
152
-	 *
153
-	 * @param string $search content to search for
154
-	 * @param string $objectType Limit the search by object type
155
-	 * @param string $objectId Limit the search by object id
156
-	 * @param string $verb Limit the verb of the comment
157
-	 * @param int $offset
158
-	 * @param int $limit
159
-	 * @return list<IComment>
160
-	 * @since 14.0.0
161
-	 */
162
-	public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array;
163
-
164
-	/**
165
-	 * Search for comments on one or more objects with a given content
166
-	 *
167
-	 * @param string $search content to search for
168
-	 * @param string $objectType Limit the search by object type
169
-	 * @param array $objectIds Limit the search by object ids
170
-	 * @param string $verb Limit the verb of the comment
171
-	 * @param int $offset
172
-	 * @param int $limit
173
-	 * @return IComment[]
174
-	 * @since 21.0.0
175
-	 */
176
-	public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array;
177
-
178
-	/**
179
-	 * @param $objectType string the object type, e.g. 'files'
180
-	 * @param $objectId string the id of the object
181
-	 * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
182
-	 *                                     that may be returned
183
-	 * @param string $verb Limit the verb of the comment - Added in 14.0.0
184
-	 * @return int
185
-	 * @since 9.0.0
186
-	 */
187
-	public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = '');
188
-
189
-	/**
190
-	 * @param $objectType string the object type, e.g. 'files'
191
-	 * @param $objectIds string[] the ids of the object
192
-	 * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
193
-	 *                                     that may be returned
194
-	 * @param string $verb Limit the verb of the comment
195
-	 * @return array<string, int>
196
-	 * @since 32.0.0
197
-	 */
198
-	public function getNumberOfCommentsForObjects(string $objectType, array $objectIds, ?\DateTime $notOlderThan = null, string $verb = ''): array;
199
-
200
-	/**
201
-	 * @param string $objectType the object type, e.g. 'files'
202
-	 * @param string[] $objectIds the id of the object
203
-	 * @param IUser $user
204
-	 * @param string $verb Limit the verb of the comment - Added in 14.0.0
205
-	 * @return array Map with object id => # of unread comments
206
-	 * @psalm-return array<string, int>
207
-	 * @since 21.0.0
208
-	 */
209
-	public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array;
210
-
211
-	/**
212
-	 * @param string $objectType
213
-	 * @param string $objectId
214
-	 * @param int $lastRead
215
-	 * @param string $verb
216
-	 * @return int
217
-	 * @since 21.0.0
218
-	 * @deprecated 24.0.0 - Use getNumberOfCommentsWithVerbsForObjectSinceComment instead
219
-	 */
220
-	public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int;
221
-
222
-
223
-	/**
224
-	 * @param string $objectType
225
-	 * @param string $objectId
226
-	 * @param int $lastRead
227
-	 * @param string[] $verbs
228
-	 * @return int
229
-	 * @since 24.0.0
230
-	 */
231
-	public function getNumberOfCommentsWithVerbsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, array $verbs): int;
232
-
233
-	/**
234
-	 * @param string $objectType
235
-	 * @param string $objectId
236
-	 * @param \DateTime $beforeDate
237
-	 * @param string $verb
238
-	 * @return int
239
-	 * @since 21.0.0
240
-	 */
241
-	public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int;
242
-
243
-	/**
244
-	 * @param string $objectType
245
-	 * @param string $objectId
246
-	 * @param string $verb
247
-	 * @param string $actorType
248
-	 * @param string[] $actors
249
-	 * @return \DateTime[] Map of "string actor" => "\DateTime most recent comment date"
250
-	 * @psalm-return array<string, \DateTime>
251
-	 * @since 21.0.0
252
-	 */
253
-	public function getLastCommentDateByActor(
254
-		string $objectType,
255
-		string $objectId,
256
-		string $verb,
257
-		string $actorType,
258
-		array $actors,
259
-	): array;
260
-
261
-	/**
262
-	 * Get the number of unread comments for all files in a folder
263
-	 *
264
-	 * @param int $folderId
265
-	 * @param IUser $user
266
-	 * @return array [$fileId => $unreadCount]
267
-	 * @since 12.0.0
268
-	 * @deprecated 29.0.0 use getNumberOfUnreadCommentsForObjects instead
269
-	 */
270
-	public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user);
271
-
272
-	/**
273
-	 * creates a new comment and returns it. At this point of time, it is not
274
-	 * saved in the used data storage. Use save() after setting other fields
275
-	 * of the comment (e.g. message or verb).
276
-	 *
277
-	 * @param string $actorType the actor type (e.g. 'users')
278
-	 * @param string $actorId a user id
279
-	 * @param string $objectType the object type the comment is attached to
280
-	 * @param string $objectId the object id the comment is attached to
281
-	 * @return IComment
282
-	 * @since 9.0.0
283
-	 */
284
-	public function create($actorType, $actorId, $objectType, $objectId);
285
-
286
-	/**
287
-	 * permanently deletes the comment specified by the ID
288
-	 *
289
-	 * When the comment has child comments, their parent ID will be changed to
290
-	 * the parent ID of the item that is to be deleted.
291
-	 *
292
-	 * @param string $id
293
-	 * @return bool
294
-	 * @since 9.0.0
295
-	 */
296
-	public function delete($id);
297
-
298
-	/**
299
-	 * Get comment related with user reaction
300
-	 *
301
-	 * Throws PreConditionNotMetException when the system haven't the minimum requirements to
302
-	 * use reactions
303
-	 *
304
-	 * @param int $parentId
305
-	 * @param string $actorType
306
-	 * @param string $actorId
307
-	 * @param string $reaction
308
-	 * @return IComment
309
-	 * @throws NotFoundException
310
-	 * @throws PreConditionNotMetException
311
-	 * @since 24.0.0
312
-	 */
313
-	public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment;
314
-
315
-	/**
316
-	 * Retrieve all reactions of a message
317
-	 *
318
-	 * Throws PreConditionNotMetException when the system haven't the minimum requirements to
319
-	 * use reactions
320
-	 *
321
-	 * @param int $parentId
322
-	 * @return IComment[]
323
-	 * @throws PreConditionNotMetException
324
-	 * @since 24.0.0
325
-	 */
326
-	public function retrieveAllReactions(int $parentId): array;
327
-
328
-	/**
329
-	 * Retrieve all reactions with specific reaction of a message
330
-	 *
331
-	 * Throws PreConditionNotMetException when the system haven't the minimum requirements to
332
-	 * use reactions
333
-	 *
334
-	 * @param int $parentId
335
-	 * @param string $reaction
336
-	 * @return IComment[]
337
-	 * @throws PreConditionNotMetException
338
-	 * @since 24.0.0
339
-	 */
340
-	public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array;
341
-
342
-	/**
343
-	 * Support reactions
344
-	 *
345
-	 * @return bool
346
-	 * @since 24.0.0
347
-	 */
348
-	public function supportReactions(): bool;
349
-
350
-	/**
351
-	 * saves the comment permanently
352
-	 *
353
-	 * if the supplied comment has an empty ID, a new entry comment will be
354
-	 * saved and the instance updated with the new ID.
355
-	 *
356
-	 * Otherwise, an existing comment will be updated.
357
-	 *
358
-	 * Throws NotFoundException when a comment that is to be updated does not
359
-	 * exist anymore at this point of time.
360
-	 *
361
-	 * @param IComment $comment
362
-	 * @return bool
363
-	 * @throws NotFoundException
364
-	 * @since 9.0.0
365
-	 */
366
-	public function save(IComment $comment);
367
-
368
-	/**
369
-	 * removes references to specific actor (e.g. on user delete) of a comment.
370
-	 * The comment itself must not get lost/deleted.
371
-	 *
372
-	 * A 'users' type actor (type and id) should get replaced by the
373
-	 * value of the DELETED_USER constant of this interface.
374
-	 *
375
-	 * @param string $actorType the actor type (e.g. 'users')
376
-	 * @param string $actorId a user id
377
-	 * @return boolean
378
-	 * @since 9.0.0
379
-	 */
380
-	public function deleteReferencesOfActor($actorType, $actorId);
381
-
382
-	/**
383
-	 * deletes all comments made of a specific object (e.g. on file delete)
384
-	 *
385
-	 * @param string $objectType the object type (e.g. 'files')
386
-	 * @param string $objectId e.g. the file id
387
-	 * @return boolean
388
-	 * @since 9.0.0
389
-	 */
390
-	public function deleteCommentsAtObject($objectType, $objectId);
391
-
392
-	/**
393
-	 * sets the read marker for a given file to the specified date for the
394
-	 * provided user
395
-	 *
396
-	 * @param string $objectType
397
-	 * @param string $objectId
398
-	 * @param \DateTime $dateTime
399
-	 * @param \OCP\IUser $user
400
-	 * @since 9.0.0
401
-	 */
402
-	public function setReadMark($objectType, $objectId, \DateTime $dateTime, \OCP\IUser $user);
403
-
404
-	/**
405
-	 * returns the read marker for a given file to the specified date for the
406
-	 * provided user. It returns null, when the marker is not present, i.e.
407
-	 * no comments were marked as read.
408
-	 *
409
-	 * @param string $objectType
410
-	 * @param string $objectId
411
-	 * @param \OCP\IUser $user
412
-	 * @return \DateTime|null
413
-	 * @since 9.0.0
414
-	 */
415
-	public function getReadMark($objectType, $objectId, \OCP\IUser $user);
416
-
417
-	/**
418
-	 * deletes the read markers for the specified user
419
-	 *
420
-	 * @param \OCP\IUser $user
421
-	 * @return bool
422
-	 * @since 9.0.0
423
-	 */
424
-	public function deleteReadMarksFromUser(\OCP\IUser $user);
425
-
426
-	/**
427
-	 * deletes the read markers on the specified object
428
-	 *
429
-	 * @param string $objectType
430
-	 * @param string $objectId
431
-	 * @return bool
432
-	 * @since 9.0.0
433
-	 */
434
-	public function deleteReadMarksOnObject($objectType, $objectId);
435
-
436
-	/**
437
-	 * registers an Entity to the manager, so event notifications can be send
438
-	 * to consumers of the comments infrastructure
439
-	 *
440
-	 * @param \Closure $closure
441
-	 * @since 11.0.0
442
-	 */
443
-	public function registerEventHandler(\Closure $closure);
444
-
445
-	/**
446
-	 * registers a method that resolves an ID to a display name for a given type
447
-	 *
448
-	 * @param string $type
449
-	 * @param \Closure $closure
450
-	 * @throws \OutOfBoundsException
451
-	 * @since 11.0.0
452
-	 *
453
-	 * Only one resolver shall be registered per type. Otherwise a
454
-	 * \OutOfBoundsException has to thrown.
455
-	 */
456
-	public function registerDisplayNameResolver($type, \Closure $closure);
457
-
458
-	/**
459
-	 * resolves a given ID of a given Type to a display name.
460
-	 *
461
-	 * @param string $type
462
-	 * @param string $id
463
-	 * @return string
464
-	 * @throws \OutOfBoundsException
465
-	 * @since 11.0.0
466
-	 *
467
-	 * If a provided type was not registered, an \OutOfBoundsException shall
468
-	 * be thrown. It is upon the resolver discretion what to return of the
469
-	 * provided ID is unknown. It must be ensured that a string is returned.
470
-	 */
471
-	public function resolveDisplayName($type, $id);
472
-
473
-	/**
474
-	 * Load the Comments app into the page
475
-	 *
476
-	 * @since 21.0.0
477
-	 */
478
-	public function load(): void;
479
-
480
-	/**
481
-	 * Delete comments with field expire_date less than current date
482
-	 * Only will delete the message related with the object.
483
-	 *
484
-	 * @param string $objectType the object type (e.g. 'files')
485
-	 * @param string $objectId e.g. the file id, leave empty to expire on all objects of this type
486
-	 * @return boolean true if at least one row was deleted
487
-	 * @since 25.0.0
488
-	 */
489
-	public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool;
21
+    /**
22
+     * @const DELETED_USER type and id for a user that has been deleted
23
+     * @see deleteReferencesOfActor
24
+     * @since 9.0.0
25
+     *
26
+     * To be used as replacement for user type actors in deleteReferencesOfActor().
27
+     *
28
+     * User interfaces shall show "Deleted user" as display name, if needed.
29
+     */
30
+    public const DELETED_USER = 'deleted_users';
31
+
32
+    /**
33
+     * returns a comment instance
34
+     *
35
+     * @param string $id the ID of the comment
36
+     * @return IComment
37
+     * @throws NotFoundException
38
+     * @since 9.0.0
39
+     */
40
+    public function get($id);
41
+
42
+    /**
43
+     * Returns the comment specified by the id and all it's child comments
44
+     *
45
+     * @param string $id
46
+     * @param int $limit max number of entries to return, 0 returns all
47
+     * @param int $offset the start entry
48
+     * @return array{comment: IComment, replies: list<array{comment: IComment, replies: array<empty, empty>}>}
49
+     * @since 9.0.0
50
+     *
51
+     * The return array looks like this
52
+     * [
53
+     * 	 'comment' => IComment, // root comment
54
+     *   'replies' =>
55
+     *   [
56
+     *     0 =>
57
+     *     [
58
+     *       'comment' => IComment,
59
+     *       'replies' =>
60
+     *       [
61
+     *         0 =>
62
+     *         [
63
+     *           'comment' => IComment,
64
+     *           'replies' => [ … ]
65
+     *         ],
66
+     *         …
67
+     *       ]
68
+     *     ]
69
+     *     1 =>
70
+     *     [
71
+     *       'comment' => IComment,
72
+     *       'replies'=> [ … ]
73
+     *     ],
74
+     *     …
75
+     *   ]
76
+     * ]
77
+     */
78
+    public function getTree($id, $limit = 0, $offset = 0);
79
+
80
+    /**
81
+     * returns comments for a specific object (e.g. a file).
82
+     *
83
+     * The sort order is always newest to oldest.
84
+     *
85
+     * @param string $objectType the object type, e.g. 'files'
86
+     * @param string $objectId the id of the object
87
+     * @param int $limit optional, number of maximum comments to be returned. if
88
+     *                   not specified, all comments are returned.
89
+     * @param int $offset optional, starting point
90
+     * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
91
+     *                                     that may be returned
92
+     * @return list<IComment>
93
+     * @since 9.0.0
94
+     */
95
+    public function getForObject(
96
+        $objectType,
97
+        $objectId,
98
+        $limit = 0,
99
+        $offset = 0,
100
+        ?\DateTime $notOlderThan = null,
101
+    );
102
+
103
+    /**
104
+     * @param string $objectType the object type, e.g. 'files'
105
+     * @param string $objectId the id of the object
106
+     * @param int $lastKnownCommentId the last known comment (will be used as offset)
107
+     * @param string $sortDirection direction of the comments (`asc` or `desc`)
108
+     * @param int $limit optional, number of maximum comments to be returned. if
109
+     *                   set to 0, all comments are returned.
110
+     * @param bool $includeLastKnown
111
+     * @param string $topmostParentId Limit the comments to a list of replies and its original root comment
112
+     * @return list<IComment>
113
+     * @since 14.0.0
114
+     * @deprecated 24.0.0 - Use getCommentsWithVerbForObjectSinceComment instead
115
+     */
116
+    public function getForObjectSince(
117
+        string $objectType,
118
+        string $objectId,
119
+        int $lastKnownCommentId,
120
+        string $sortDirection = 'asc',
121
+        int $limit = 30,
122
+        bool $includeLastKnown = false,
123
+        string $topmostParentId = '',
124
+    ): array;
125
+
126
+    /**
127
+     * @param string $objectType the object type, e.g. 'files'
128
+     * @param string $objectId the id of the object
129
+     * @param string[] $verbs List of verbs to filter by
130
+     * @param int $lastKnownCommentId the last known comment (will be used as offset)
131
+     * @param string $sortDirection direction of the comments (`asc` or `desc`)
132
+     * @param int $limit optional, number of maximum comments to be returned. if
133
+     *                   set to 0, all comments are returned.
134
+     * @param bool $includeLastKnown
135
+     * @param string $topmostParentId Limit the comments to a list of replies and its original root comment
136
+     * @return list<IComment>
137
+     * @since 24.0.0
138
+     */
139
+    public function getCommentsWithVerbForObjectSinceComment(
140
+        string $objectType,
141
+        string $objectId,
142
+        array $verbs,
143
+        int $lastKnownCommentId,
144
+        string $sortDirection = 'asc',
145
+        int $limit = 30,
146
+        bool $includeLastKnown = false,
147
+        string $topmostParentId = '',
148
+    ): array;
149
+
150
+    /**
151
+     * Search for comments with a given content
152
+     *
153
+     * @param string $search content to search for
154
+     * @param string $objectType Limit the search by object type
155
+     * @param string $objectId Limit the search by object id
156
+     * @param string $verb Limit the verb of the comment
157
+     * @param int $offset
158
+     * @param int $limit
159
+     * @return list<IComment>
160
+     * @since 14.0.0
161
+     */
162
+    public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array;
163
+
164
+    /**
165
+     * Search for comments on one or more objects with a given content
166
+     *
167
+     * @param string $search content to search for
168
+     * @param string $objectType Limit the search by object type
169
+     * @param array $objectIds Limit the search by object ids
170
+     * @param string $verb Limit the verb of the comment
171
+     * @param int $offset
172
+     * @param int $limit
173
+     * @return IComment[]
174
+     * @since 21.0.0
175
+     */
176
+    public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array;
177
+
178
+    /**
179
+     * @param $objectType string the object type, e.g. 'files'
180
+     * @param $objectId string the id of the object
181
+     * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
182
+     *                                     that may be returned
183
+     * @param string $verb Limit the verb of the comment - Added in 14.0.0
184
+     * @return int
185
+     * @since 9.0.0
186
+     */
187
+    public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = '');
188
+
189
+    /**
190
+     * @param $objectType string the object type, e.g. 'files'
191
+     * @param $objectIds string[] the ids of the object
192
+     * @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
193
+     *                                     that may be returned
194
+     * @param string $verb Limit the verb of the comment
195
+     * @return array<string, int>
196
+     * @since 32.0.0
197
+     */
198
+    public function getNumberOfCommentsForObjects(string $objectType, array $objectIds, ?\DateTime $notOlderThan = null, string $verb = ''): array;
199
+
200
+    /**
201
+     * @param string $objectType the object type, e.g. 'files'
202
+     * @param string[] $objectIds the id of the object
203
+     * @param IUser $user
204
+     * @param string $verb Limit the verb of the comment - Added in 14.0.0
205
+     * @return array Map with object id => # of unread comments
206
+     * @psalm-return array<string, int>
207
+     * @since 21.0.0
208
+     */
209
+    public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array;
210
+
211
+    /**
212
+     * @param string $objectType
213
+     * @param string $objectId
214
+     * @param int $lastRead
215
+     * @param string $verb
216
+     * @return int
217
+     * @since 21.0.0
218
+     * @deprecated 24.0.0 - Use getNumberOfCommentsWithVerbsForObjectSinceComment instead
219
+     */
220
+    public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int;
221
+
222
+
223
+    /**
224
+     * @param string $objectType
225
+     * @param string $objectId
226
+     * @param int $lastRead
227
+     * @param string[] $verbs
228
+     * @return int
229
+     * @since 24.0.0
230
+     */
231
+    public function getNumberOfCommentsWithVerbsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, array $verbs): int;
232
+
233
+    /**
234
+     * @param string $objectType
235
+     * @param string $objectId
236
+     * @param \DateTime $beforeDate
237
+     * @param string $verb
238
+     * @return int
239
+     * @since 21.0.0
240
+     */
241
+    public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int;
242
+
243
+    /**
244
+     * @param string $objectType
245
+     * @param string $objectId
246
+     * @param string $verb
247
+     * @param string $actorType
248
+     * @param string[] $actors
249
+     * @return \DateTime[] Map of "string actor" => "\DateTime most recent comment date"
250
+     * @psalm-return array<string, \DateTime>
251
+     * @since 21.0.0
252
+     */
253
+    public function getLastCommentDateByActor(
254
+        string $objectType,
255
+        string $objectId,
256
+        string $verb,
257
+        string $actorType,
258
+        array $actors,
259
+    ): array;
260
+
261
+    /**
262
+     * Get the number of unread comments for all files in a folder
263
+     *
264
+     * @param int $folderId
265
+     * @param IUser $user
266
+     * @return array [$fileId => $unreadCount]
267
+     * @since 12.0.0
268
+     * @deprecated 29.0.0 use getNumberOfUnreadCommentsForObjects instead
269
+     */
270
+    public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user);
271
+
272
+    /**
273
+     * creates a new comment and returns it. At this point of time, it is not
274
+     * saved in the used data storage. Use save() after setting other fields
275
+     * of the comment (e.g. message or verb).
276
+     *
277
+     * @param string $actorType the actor type (e.g. 'users')
278
+     * @param string $actorId a user id
279
+     * @param string $objectType the object type the comment is attached to
280
+     * @param string $objectId the object id the comment is attached to
281
+     * @return IComment
282
+     * @since 9.0.0
283
+     */
284
+    public function create($actorType, $actorId, $objectType, $objectId);
285
+
286
+    /**
287
+     * permanently deletes the comment specified by the ID
288
+     *
289
+     * When the comment has child comments, their parent ID will be changed to
290
+     * the parent ID of the item that is to be deleted.
291
+     *
292
+     * @param string $id
293
+     * @return bool
294
+     * @since 9.0.0
295
+     */
296
+    public function delete($id);
297
+
298
+    /**
299
+     * Get comment related with user reaction
300
+     *
301
+     * Throws PreConditionNotMetException when the system haven't the minimum requirements to
302
+     * use reactions
303
+     *
304
+     * @param int $parentId
305
+     * @param string $actorType
306
+     * @param string $actorId
307
+     * @param string $reaction
308
+     * @return IComment
309
+     * @throws NotFoundException
310
+     * @throws PreConditionNotMetException
311
+     * @since 24.0.0
312
+     */
313
+    public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment;
314
+
315
+    /**
316
+     * Retrieve all reactions of a message
317
+     *
318
+     * Throws PreConditionNotMetException when the system haven't the minimum requirements to
319
+     * use reactions
320
+     *
321
+     * @param int $parentId
322
+     * @return IComment[]
323
+     * @throws PreConditionNotMetException
324
+     * @since 24.0.0
325
+     */
326
+    public function retrieveAllReactions(int $parentId): array;
327
+
328
+    /**
329
+     * Retrieve all reactions with specific reaction of a message
330
+     *
331
+     * Throws PreConditionNotMetException when the system haven't the minimum requirements to
332
+     * use reactions
333
+     *
334
+     * @param int $parentId
335
+     * @param string $reaction
336
+     * @return IComment[]
337
+     * @throws PreConditionNotMetException
338
+     * @since 24.0.0
339
+     */
340
+    public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array;
341
+
342
+    /**
343
+     * Support reactions
344
+     *
345
+     * @return bool
346
+     * @since 24.0.0
347
+     */
348
+    public function supportReactions(): bool;
349
+
350
+    /**
351
+     * saves the comment permanently
352
+     *
353
+     * if the supplied comment has an empty ID, a new entry comment will be
354
+     * saved and the instance updated with the new ID.
355
+     *
356
+     * Otherwise, an existing comment will be updated.
357
+     *
358
+     * Throws NotFoundException when a comment that is to be updated does not
359
+     * exist anymore at this point of time.
360
+     *
361
+     * @param IComment $comment
362
+     * @return bool
363
+     * @throws NotFoundException
364
+     * @since 9.0.0
365
+     */
366
+    public function save(IComment $comment);
367
+
368
+    /**
369
+     * removes references to specific actor (e.g. on user delete) of a comment.
370
+     * The comment itself must not get lost/deleted.
371
+     *
372
+     * A 'users' type actor (type and id) should get replaced by the
373
+     * value of the DELETED_USER constant of this interface.
374
+     *
375
+     * @param string $actorType the actor type (e.g. 'users')
376
+     * @param string $actorId a user id
377
+     * @return boolean
378
+     * @since 9.0.0
379
+     */
380
+    public function deleteReferencesOfActor($actorType, $actorId);
381
+
382
+    /**
383
+     * deletes all comments made of a specific object (e.g. on file delete)
384
+     *
385
+     * @param string $objectType the object type (e.g. 'files')
386
+     * @param string $objectId e.g. the file id
387
+     * @return boolean
388
+     * @since 9.0.0
389
+     */
390
+    public function deleteCommentsAtObject($objectType, $objectId);
391
+
392
+    /**
393
+     * sets the read marker for a given file to the specified date for the
394
+     * provided user
395
+     *
396
+     * @param string $objectType
397
+     * @param string $objectId
398
+     * @param \DateTime $dateTime
399
+     * @param \OCP\IUser $user
400
+     * @since 9.0.0
401
+     */
402
+    public function setReadMark($objectType, $objectId, \DateTime $dateTime, \OCP\IUser $user);
403
+
404
+    /**
405
+     * returns the read marker for a given file to the specified date for the
406
+     * provided user. It returns null, when the marker is not present, i.e.
407
+     * no comments were marked as read.
408
+     *
409
+     * @param string $objectType
410
+     * @param string $objectId
411
+     * @param \OCP\IUser $user
412
+     * @return \DateTime|null
413
+     * @since 9.0.0
414
+     */
415
+    public function getReadMark($objectType, $objectId, \OCP\IUser $user);
416
+
417
+    /**
418
+     * deletes the read markers for the specified user
419
+     *
420
+     * @param \OCP\IUser $user
421
+     * @return bool
422
+     * @since 9.0.0
423
+     */
424
+    public function deleteReadMarksFromUser(\OCP\IUser $user);
425
+
426
+    /**
427
+     * deletes the read markers on the specified object
428
+     *
429
+     * @param string $objectType
430
+     * @param string $objectId
431
+     * @return bool
432
+     * @since 9.0.0
433
+     */
434
+    public function deleteReadMarksOnObject($objectType, $objectId);
435
+
436
+    /**
437
+     * registers an Entity to the manager, so event notifications can be send
438
+     * to consumers of the comments infrastructure
439
+     *
440
+     * @param \Closure $closure
441
+     * @since 11.0.0
442
+     */
443
+    public function registerEventHandler(\Closure $closure);
444
+
445
+    /**
446
+     * registers a method that resolves an ID to a display name for a given type
447
+     *
448
+     * @param string $type
449
+     * @param \Closure $closure
450
+     * @throws \OutOfBoundsException
451
+     * @since 11.0.0
452
+     *
453
+     * Only one resolver shall be registered per type. Otherwise a
454
+     * \OutOfBoundsException has to thrown.
455
+     */
456
+    public function registerDisplayNameResolver($type, \Closure $closure);
457
+
458
+    /**
459
+     * resolves a given ID of a given Type to a display name.
460
+     *
461
+     * @param string $type
462
+     * @param string $id
463
+     * @return string
464
+     * @throws \OutOfBoundsException
465
+     * @since 11.0.0
466
+     *
467
+     * If a provided type was not registered, an \OutOfBoundsException shall
468
+     * be thrown. It is upon the resolver discretion what to return of the
469
+     * provided ID is unknown. It must be ensured that a string is returned.
470
+     */
471
+    public function resolveDisplayName($type, $id);
472
+
473
+    /**
474
+     * Load the Comments app into the page
475
+     *
476
+     * @since 21.0.0
477
+     */
478
+    public function load(): void;
479
+
480
+    /**
481
+     * Delete comments with field expire_date less than current date
482
+     * Only will delete the message related with the object.
483
+     *
484
+     * @param string $objectType the object type (e.g. 'files')
485
+     * @param string $objectId e.g. the file id, leave empty to expire on all objects of this type
486
+     * @return boolean true if at least one row was deleted
487
+     * @since 25.0.0
488
+     */
489
+    public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool;
490 490
 }
Please login to merge, or discard this patch.
tests/lib/Comments/FakeManager.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -16,144 +16,144 @@
 block discarded – undo
16 16
  * Class FakeManager
17 17
  */
18 18
 class FakeManager implements ICommentsManager {
19
-	public function get($id) {
20
-	}
21
-
22
-	public function getTree($id, $limit = 0, $offset = 0) {
23
-	}
24
-
25
-	public function getForObject(
26
-		$objectType,
27
-		$objectId,
28
-		$limit = 0,
29
-		$offset = 0,
30
-		?\DateTime $notOlderThan = null,
31
-	) {
32
-	}
19
+    public function get($id) {
20
+    }
21
+
22
+    public function getTree($id, $limit = 0, $offset = 0) {
23
+    }
24
+
25
+    public function getForObject(
26
+        $objectType,
27
+        $objectId,
28
+        $limit = 0,
29
+        $offset = 0,
30
+        ?\DateTime $notOlderThan = null,
31
+    ) {
32
+    }
33 33
 
34
-	public function getForObjectSince(
35
-		string $objectType,
36
-		string $objectId,
37
-		int $lastKnownCommentId,
38
-		string $sortDirection = 'asc',
39
-		int $limit = 30,
40
-		bool $includeLastKnown = false,
41
-		string $topmostParentId = '',
42
-	): array {
43
-		return [];
44
-	}
34
+    public function getForObjectSince(
35
+        string $objectType,
36
+        string $objectId,
37
+        int $lastKnownCommentId,
38
+        string $sortDirection = 'asc',
39
+        int $limit = 30,
40
+        bool $includeLastKnown = false,
41
+        string $topmostParentId = '',
42
+    ): array {
43
+        return [];
44
+    }
45 45
 
46
-	public function getCommentsWithVerbForObjectSinceComment(
47
-		string $objectType,
48
-		string $objectId,
49
-		array $verbs,
50
-		int $lastKnownCommentId,
51
-		string $sortDirection = 'asc',
52
-		int $limit = 30,
53
-		bool $includeLastKnown = false,
54
-		string $topmostParentId = '',
55
-	): array {
56
-		return [];
57
-	}
58
-
59
-	public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = ''): int {
60
-	}
61
-
62
-	public function getNumberOfCommentsForObjects(string $objectType, array $objectIds, ?\DateTime $notOlderThan = null, string $verb = ''): array {
63
-		return array_fill_keys($objectIds, 0);
64
-	}
65
-
66
-	public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array {
67
-		return [];
68
-	}
69
-
70
-	public function create($actorType, $actorId, $objectType, $objectId) {
71
-	}
72
-
73
-	public function delete($id) {
74
-	}
75
-
76
-	public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment {
77
-		return new Comment();
78
-	}
79
-
80
-	public function retrieveAllReactions(int $parentId): array {
81
-		return [];
82
-	}
83
-
84
-	public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array {
85
-		return [];
86
-	}
87
-
88
-	public function supportReactions(): bool {
89
-		return false;
90
-	}
91
-
92
-	public function save(IComment $comment) {
93
-	}
94
-
95
-	public function deleteReferencesOfActor($actorType, $actorId) {
96
-	}
97
-
98
-	public function deleteCommentsAtObject($objectType, $objectId) {
99
-	}
100
-
101
-	public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) {
102
-	}
103
-
104
-	public function getReadMark($objectType, $objectId, IUser $user) {
105
-	}
106
-
107
-	public function deleteReadMarksFromUser(IUser $user) {
108
-	}
109
-
110
-	public function deleteReadMarksOnObject($objectType, $objectId) {
111
-	}
112
-
113
-	public function registerEventHandler(\Closure $closure) {
114
-	}
115
-
116
-	public function registerDisplayNameResolver($type, \Closure $closure) {
117
-	}
118
-
119
-	public function resolveDisplayName($type, $id) {
120
-	}
46
+    public function getCommentsWithVerbForObjectSinceComment(
47
+        string $objectType,
48
+        string $objectId,
49
+        array $verbs,
50
+        int $lastKnownCommentId,
51
+        string $sortDirection = 'asc',
52
+        int $limit = 30,
53
+        bool $includeLastKnown = false,
54
+        string $topmostParentId = '',
55
+    ): array {
56
+        return [];
57
+    }
58
+
59
+    public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = ''): int {
60
+    }
61
+
62
+    public function getNumberOfCommentsForObjects(string $objectType, array $objectIds, ?\DateTime $notOlderThan = null, string $verb = ''): array {
63
+        return array_fill_keys($objectIds, 0);
64
+    }
65
+
66
+    public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array {
67
+        return [];
68
+    }
69
+
70
+    public function create($actorType, $actorId, $objectType, $objectId) {
71
+    }
72
+
73
+    public function delete($id) {
74
+    }
75
+
76
+    public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment {
77
+        return new Comment();
78
+    }
79
+
80
+    public function retrieveAllReactions(int $parentId): array {
81
+        return [];
82
+    }
83
+
84
+    public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array {
85
+        return [];
86
+    }
87
+
88
+    public function supportReactions(): bool {
89
+        return false;
90
+    }
91
+
92
+    public function save(IComment $comment) {
93
+    }
94
+
95
+    public function deleteReferencesOfActor($actorType, $actorId) {
96
+    }
97
+
98
+    public function deleteCommentsAtObject($objectType, $objectId) {
99
+    }
100
+
101
+    public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) {
102
+    }
103
+
104
+    public function getReadMark($objectType, $objectId, IUser $user) {
105
+    }
106
+
107
+    public function deleteReadMarksFromUser(IUser $user) {
108
+    }
109
+
110
+    public function deleteReadMarksOnObject($objectType, $objectId) {
111
+    }
112
+
113
+    public function registerEventHandler(\Closure $closure) {
114
+    }
115
+
116
+    public function registerDisplayNameResolver($type, \Closure $closure) {
117
+    }
118
+
119
+    public function resolveDisplayName($type, $id) {
120
+    }
121 121
 
122
-	public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) {
123
-	}
122
+    public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) {
123
+    }
124 124
 
125
-	public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array {
126
-		return [];
127
-	}
125
+    public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array {
126
+        return [];
127
+    }
128 128
 
129 129
 
130
-	public function getActorsInTree($id) {
131
-	}
130
+    public function getActorsInTree($id) {
131
+    }
132 132
 
133
-	public function load(): void {
134
-	}
133
+    public function load(): void {
134
+    }
135 135
 
136
-	public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array {
137
-		return [];
138
-	}
136
+    public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array {
137
+        return [];
138
+    }
139 139
 
140
-	public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int {
141
-		return 0;
142
-	}
140
+    public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int {
141
+        return 0;
142
+    }
143 143
 
144
-	public function getNumberOfCommentsWithVerbsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, array $verbs): int {
145
-		return 0;
146
-	}
144
+    public function getNumberOfCommentsWithVerbsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, array $verbs): int {
145
+        return 0;
146
+    }
147 147
 
148
-	public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int {
149
-		return 0;
150
-	}
148
+    public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int {
149
+        return 0;
150
+    }
151 151
 
152
-	public function getLastCommentDateByActor(string $objectType, string $objectId, string $verb, string $actorType, array $actors): array {
153
-		return [];
154
-	}
152
+    public function getLastCommentDateByActor(string $objectType, string $objectId, string $verb, string $actorType, array $actors): array {
153
+        return [];
154
+    }
155 155
 
156
-	public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool {
157
-		return true;
158
-	}
156
+    public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool {
157
+        return true;
158
+    }
159 159
 }
Please login to merge, or discard this patch.