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