aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/comment.ts36
-rw-r--r--server/initializers/constants.ts3
-rw-r--r--server/middlewares/validators/sort.ts3
-rw-r--r--server/middlewares/validators/users.ts1
-rw-r--r--server/middlewares/validators/videos/video-comments.ts33
-rw-r--r--server/models/video/video-comment.ts140
-rw-r--r--server/tests/api/check-params/users.ts12
-rw-r--r--server/tests/api/check-params/video-comments.ts48
-rw-r--r--server/tests/api/live/live.ts1
-rw-r--r--server/tests/api/videos/multiple-servers.ts2
-rw-r--r--server/tests/api/videos/video-comments.ts356
-rw-r--r--server/tests/api/videos/video-playlists.ts4
-rw-r--r--server/types/models/video/video-comment.ts9
13 files changed, 478 insertions, 170 deletions
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 45ff969d9..ccd76c093 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { ResultList } from '../../../../shared/models' 2import { ResultList, UserRight } from '../../../../shared/models'
3import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model' 3import { VideoCommentCreate } from '../../../../shared/models/videos/video-comment.model'
4import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' 4import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
5import { getFormattedObjects } from '../../../helpers/utils' 5import { getFormattedObjects } from '../../../helpers/utils'
@@ -11,6 +11,7 @@ import {
11 asyncMiddleware, 11 asyncMiddleware,
12 asyncRetryTransactionMiddleware, 12 asyncRetryTransactionMiddleware,
13 authenticate, 13 authenticate,
14 ensureUserHasRight,
14 optionalAuthenticate, 15 optionalAuthenticate,
15 paginationValidator, 16 paginationValidator,
16 setDefaultPagination, 17 setDefaultPagination,
@@ -19,9 +20,11 @@ import {
19import { 20import {
20 addVideoCommentReplyValidator, 21 addVideoCommentReplyValidator,
21 addVideoCommentThreadValidator, 22 addVideoCommentThreadValidator,
23 listVideoCommentsValidator,
22 listVideoCommentThreadsValidator, 24 listVideoCommentThreadsValidator,
23 listVideoThreadCommentsValidator, 25 listVideoThreadCommentsValidator,
24 removeVideoCommentValidator, 26 removeVideoCommentValidator,
27 videoCommentsValidator,
25 videoCommentThreadsSortValidator 28 videoCommentThreadsSortValidator
26} from '../../../middlewares/validators' 29} from '../../../middlewares/validators'
27import { AccountModel } from '../../../models/account/account' 30import { AccountModel } from '../../../models/account/account'
@@ -61,6 +64,17 @@ videoCommentRouter.delete('/:videoId/comments/:commentId',
61 asyncRetryTransactionMiddleware(removeVideoComment) 64 asyncRetryTransactionMiddleware(removeVideoComment)
62) 65)
63 66
67videoCommentRouter.get('/comments',
68 authenticate,
69 ensureUserHasRight(UserRight.SEE_ALL_COMMENTS),
70 paginationValidator,
71 videoCommentsValidator,
72 setDefaultSort,
73 setDefaultPagination,
74 listVideoCommentsValidator,
75 asyncMiddleware(listComments)
76)
77
64// --------------------------------------------------------------------------- 78// ---------------------------------------------------------------------------
65 79
66export { 80export {
@@ -69,6 +83,26 @@ export {
69 83
70// --------------------------------------------------------------------------- 84// ---------------------------------------------------------------------------
71 85
86async function listComments (req: express.Request, res: express.Response) {
87 const options = {
88 start: req.query.start,
89 count: req.query.count,
90 sort: req.query.sort,
91
92 isLocal: req.query.isLocal,
93 search: req.query.search,
94 searchAccount: req.query.searchAccount,
95 searchVideo: req.query.searchVideo
96 }
97
98 const resultList = await VideoCommentModel.listCommentsForApi(options)
99
100 return res.json({
101 total: resultList.total,
102 data: resultList.data.map(c => c.toFormattedAdminJSON())
103 })
104}
105
72async function listVideoThreads (req: express.Request, res: express.Response) { 106async function listVideoThreads (req: express.Request, res: express.Response) {
73 const video = res.locals.onlyVideo 107 const video = res.locals.onlyVideo
74 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined 108 const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 02e42a594..fde87d9f8 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -63,7 +63,10 @@ const SORTABLE_COLUMNS = {
63 JOBS: [ 'createdAt' ], 63 JOBS: [ 'createdAt' ],
64 VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ], 64 VIDEO_CHANNELS: [ 'id', 'name', 'updatedAt', 'createdAt' ],
65 VIDEO_IMPORTS: [ 'createdAt' ], 65 VIDEO_IMPORTS: [ 'createdAt' ],
66
66 VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ], 67 VIDEO_COMMENT_THREADS: [ 'createdAt', 'totalReplies' ],
68 VIDEO_COMMENTS: [ 'createdAt' ],
69
67 VIDEO_RATES: [ 'createdAt' ], 70 VIDEO_RATES: [ 'createdAt' ],
68 BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], 71 BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ],
69 FOLLOWERS: [ 'createdAt', 'state', 'score' ], 72 FOLLOWERS: [ 'createdAt', 'state', 'score' ],
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts
index 29aba0436..e93ceb200 100644
--- a/server/middlewares/validators/sort.ts
+++ b/server/middlewares/validators/sort.ts
@@ -10,6 +10,7 @@ const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS)
10const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH) 10const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH)
11const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH) 11const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH)
12const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS) 12const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS)
13const SORTABLE_VIDEO_COMMENTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
13const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS) 14const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
14const SORTABLE_VIDEO_RATES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_RATES) 15const SORTABLE_VIDEO_RATES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_RATES)
15const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS) 16const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS)
@@ -33,6 +34,7 @@ const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS)
33const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS) 34const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS)
34const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS) 35const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS)
35const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS) 36const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS)
37const videoCommentsValidator = checkSort(SORTABLE_VIDEO_COMMENTS_COLUMNS)
36const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS) 38const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS)
37const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS) 39const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS)
38const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS) 40const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS)
@@ -55,6 +57,7 @@ export {
55 abusesSortValidator, 57 abusesSortValidator,
56 videoChannelsSortValidator, 58 videoChannelsSortValidator,
57 videoImportsSortValidator, 59 videoImportsSortValidator,
60 videoCommentsValidator,
58 videosSearchSortValidator, 61 videosSearchSortValidator,
59 videosSortValidator, 62 videosSortValidator,
60 blacklistSortValidator, 63 blacklistSortValidator,
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 452c7fb93..c91c378b3 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -41,6 +41,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
41const usersListValidator = [ 41const usersListValidator = [
42 query('blocked') 42 query('blocked')
43 .optional() 43 .optional()
44 .customSanitizer(toBooleanOrNull)
44 .isBoolean().withMessage('Should be a valid boolean banned state'), 45 .isBoolean().withMessage('Should be a valid boolean banned state'),
45 46
46 (req: express.Request, res: express.Response, next: express.NextFunction) => { 47 (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 77f5c6ff3..a3c9febc4 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -1,8 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { MUserAccountUrl } from '@server/types/models' 3import { MUserAccountUrl } from '@server/types/models'
4import { UserRight } from '../../../../shared' 4import { UserRight } from '../../../../shared'
5import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 5import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
6import { 6import {
7 doesVideoCommentExist, 7 doesVideoCommentExist,
8 doesVideoCommentThreadExist, 8 doesVideoCommentThreadExist,
@@ -15,6 +15,34 @@ import { Hooks } from '../../../lib/plugins/hooks'
15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' 15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video'
16import { areValidationErrors } from '../utils' 16import { areValidationErrors } from '../utils'
17 17
18const listVideoCommentsValidator = [
19 query('isLocal')
20 .optional()
21 .customSanitizer(toBooleanOrNull)
22 .custom(isBooleanValid)
23 .withMessage('Should have a valid is local boolean'),
24
25 query('search')
26 .optional()
27 .custom(exists).withMessage('Should have a valid search'),
28
29 query('searchAccount')
30 .optional()
31 .custom(exists).withMessage('Should have a valid account search'),
32
33 query('searchVideo')
34 .optional()
35 .custom(exists).withMessage('Should have a valid video search'),
36
37 (req: express.Request, res: express.Response, next: express.NextFunction) => {
38 logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
39
40 if (areValidationErrors(req, res)) return
41
42 return next()
43 }
44]
45
18const listVideoCommentThreadsValidator = [ 46const listVideoCommentThreadsValidator = [
19 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 47 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
20 48
@@ -116,6 +144,7 @@ export {
116 listVideoCommentThreadsValidator, 144 listVideoCommentThreadsValidator,
117 listVideoThreadCommentsValidator, 145 listVideoThreadCommentsValidator,
118 addVideoCommentThreadValidator, 146 addVideoCommentThreadValidator,
147 listVideoCommentsValidator,
119 addVideoCommentReplyValidator, 148 addVideoCommentReplyValidator,
120 videoCommentGetValidator, 149 videoCommentGetValidator,
121 removeVideoCommentValidator 150 removeVideoCommentValidator
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index de27b3d87..ed4a345eb 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -1,6 +1,6 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { uniq } from 'lodash' 2import { uniq } from 'lodash'
3import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize' 3import { FindAndCountOptions, FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction, WhereOptions } from 'sequelize'
4import { 4import {
5 AllowNull, 5 AllowNull,
6 BelongsTo, 6 BelongsTo,
@@ -20,13 +20,14 @@ import { MAccount, MAccountId, MUserAccountId } from '@server/types/models'
20import { VideoPrivacy } from '@shared/models' 20import { VideoPrivacy } from '@shared/models'
21import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects' 21import { ActivityTagObject, ActivityTombstoneObject } from '../../../shared/models/activitypub/objects/common-objects'
22import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' 22import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object'
23import { VideoComment } from '../../../shared/models/videos/video-comment.model' 23import { VideoComment, VideoCommentAdmin } from '../../../shared/models/videos/video-comment.model'
24import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' 24import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor'
25import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 25import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
26import { regexpCapture } from '../../helpers/regexp' 26import { regexpCapture } from '../../helpers/regexp'
27import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' 27import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants'
28import { 28import {
29 MComment, 29 MComment,
30 MCommentAdminFormattable,
30 MCommentAP, 31 MCommentAP,
31 MCommentFormattable, 32 MCommentFormattable,
32 MCommentId, 33 MCommentId,
@@ -40,7 +41,14 @@ import {
40import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse' 41import { VideoCommentAbuseModel } from '../abuse/video-comment-abuse'
41import { AccountModel } from '../account/account' 42import { AccountModel } from '../account/account'
42import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' 43import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
43import { buildBlockedAccountSQL, buildBlockedAccountSQLOptimized, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' 44import {
45 buildBlockedAccountSQL,
46 buildBlockedAccountSQLOptimized,
47 buildLocalAccountIdsIn,
48 getCommentSort,
49 searchAttribute,
50 throwIfNotValid
51} from '../utils'
44import { VideoModel } from './video' 52import { VideoModel } from './video'
45import { VideoChannelModel } from './video-channel' 53import { VideoChannelModel } from './video-channel'
46 54
@@ -303,6 +311,98 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
303 return VideoCommentModel.scope([ ScopeNames.WITH_IN_REPLY_TO, ScopeNames.WITH_ACCOUNT ]).findOne(query) 311 return VideoCommentModel.scope([ ScopeNames.WITH_IN_REPLY_TO, ScopeNames.WITH_ACCOUNT ]).findOne(query)
304 } 312 }
305 313
314 static listCommentsForApi (parameters: {
315 start: number
316 count: number
317 sort: string
318
319 isLocal?: boolean
320 search?: string
321 searchAccount?: string
322 searchVideo?: string
323 }) {
324 const { start, count, sort, isLocal, search, searchAccount, searchVideo } = parameters
325
326 const where: WhereOptions = {
327 deletedAt: null
328 }
329
330 const whereAccount: WhereOptions = {}
331 const whereActor: WhereOptions = {}
332 const whereVideo: WhereOptions = {}
333
334 if (isLocal === true) {
335 Object.assign(whereActor, {
336 serverId: null
337 })
338 } else if (isLocal === false) {
339 Object.assign(whereActor, {
340 serverId: {
341 [Op.ne]: null
342 }
343 })
344 }
345
346 if (search) {
347 Object.assign(where, {
348 [Op.or]: [
349 searchAttribute(search, 'text'),
350 searchAttribute(search, '$Account.Actor.preferredUsername$'),
351 searchAttribute(search, '$Account.name$'),
352 searchAttribute(search, '$Video.name$')
353 ]
354 })
355 }
356
357 if (searchAccount) {
358 Object.assign(whereActor, {
359 [Op.or]: [
360 searchAttribute(searchAccount, '$Account.Actor.preferredUsername$'),
361 searchAttribute(searchAccount, '$Account.name$')
362 ]
363 })
364 }
365
366 if (searchVideo) {
367 Object.assign(whereVideo, searchAttribute(searchVideo, 'name'))
368 }
369
370 const query: FindAndCountOptions = {
371 offset: start,
372 limit: count,
373 order: getCommentSort(sort),
374 where,
375 include: [
376 {
377 model: AccountModel.unscoped(),
378 required: true,
379 where: whereAccount,
380 include: [
381 {
382 attributes: {
383 exclude: unusedActorAttributesForAPI
384 },
385 model: ActorModel, // Default scope includes avatar and server
386 required: true,
387 where: whereActor
388 }
389 ]
390 },
391 {
392 model: VideoModel.unscoped(),
393 required: true,
394 where: whereVideo
395 }
396 ]
397 }
398
399 return VideoCommentModel
400 .findAndCountAll(query)
401 .then(({ rows, count }) => {
402 return { total: count, data: rows }
403 })
404 }
405
306 static async listThreadsForApi (parameters: { 406 static async listThreadsForApi (parameters: {
307 videoId: number 407 videoId: number
308 isVideoOwned: boolean 408 isVideoOwned: boolean
@@ -656,19 +756,51 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
656 id: this.id, 756 id: this.id,
657 url: this.url, 757 url: this.url,
658 text: this.text, 758 text: this.text,
759
659 threadId: this.getThreadId(), 760 threadId: this.getThreadId(),
660 inReplyToCommentId: this.inReplyToCommentId || null, 761 inReplyToCommentId: this.inReplyToCommentId || null,
661 videoId: this.videoId, 762 videoId: this.videoId,
763
662 createdAt: this.createdAt, 764 createdAt: this.createdAt,
663 updatedAt: this.updatedAt, 765 updatedAt: this.updatedAt,
664 deletedAt: this.deletedAt, 766 deletedAt: this.deletedAt,
767
665 isDeleted: this.isDeleted(), 768 isDeleted: this.isDeleted(),
769
666 totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0, 770 totalRepliesFromVideoAuthor: this.get('totalRepliesFromVideoAuthor') || 0,
667 totalReplies: this.get('totalReplies') || 0, 771 totalReplies: this.get('totalReplies') || 0,
668 account: this.Account ? this.Account.toFormattedJSON() : null 772
773 account: this.Account
774 ? this.Account.toFormattedJSON()
775 : null
669 } as VideoComment 776 } as VideoComment
670 } 777 }
671 778
779 toFormattedAdminJSON (this: MCommentAdminFormattable) {
780 return {
781 id: this.id,
782 url: this.url,
783 text: this.text,
784
785 threadId: this.getThreadId(),
786 inReplyToCommentId: this.inReplyToCommentId || null,
787 videoId: this.videoId,
788
789 createdAt: this.createdAt,
790 updatedAt: this.updatedAt,
791
792 video: {
793 id: this.Video.id,
794 uuid: this.Video.uuid,
795 name: this.Video.name
796 },
797
798 account: this.Account
799 ? this.Account.toFormattedJSON()
800 : null
801 } as VideoCommentAdmin
802 }
803
672 toActivityPubObject (this: MCommentAP, threadParentComments: MCommentOwner[]): VideoCommentObject | ActivityTombstoneObject { 804 toActivityPubObject (this: MCommentAP, threadParentComments: MCommentOwner[]): VideoCommentObject | ActivityTombstoneObject {
673 let inReplyTo: string 805 let inReplyTo: string
674 // New thread, so in AS we reply to the video 806 // New thread, so in AS we reply to the video
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 3e53c445d..2a220be83 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -154,18 +154,6 @@ describe('Test users API validators', function () {
154 await checkBadSortPagination(server.url, path, server.accessToken) 154 await checkBadSortPagination(server.url, path, server.accessToken)
155 }) 155 })
156 156
157 it('Should fail with a bad blocked/banned user filter', async function () {
158 await makeGetRequest({
159 url: server.url,
160 path,
161 query: {
162 blocked: 42
163 },
164 token: server.accessToken,
165 statusCodeExpected: 400
166 })
167 })
168
169 it('Should fail with a non authenticated user', async function () { 157 it('Should fail with a non authenticated user', async function () {
170 await makeGetRequest({ 158 await makeGetRequest({
171 url: server.url, 159 url: server.url,
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 181282ce1..662d4a70d 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -296,6 +296,54 @@ describe('Test video comments API validator', function () {
296 it('Should return conflict on comment thread add') 296 it('Should return conflict on comment thread add')
297 }) 297 })
298 298
299 describe('When listing admin comments threads', function () {
300 const path = '/api/v1/videos/comments'
301
302 it('Should fail with a bad start pagination', async function () {
303 await checkBadStartPagination(server.url, path, server.accessToken)
304 })
305
306 it('Should fail with a bad count pagination', async function () {
307 await checkBadCountPagination(server.url, path, server.accessToken)
308 })
309
310 it('Should fail with an incorrect sort', async function () {
311 await checkBadSortPagination(server.url, path, server.accessToken)
312 })
313
314 it('Should fail with a non authenticated user', async function () {
315 await makeGetRequest({
316 url: server.url,
317 path,
318 statusCodeExpected: 401
319 })
320 })
321
322 it('Should fail with a non admin user', async function () {
323 await makeGetRequest({
324 url: server.url,
325 path,
326 token: userAccessToken,
327 statusCodeExpected: 403
328 })
329 })
330
331 it('Should succeed with the correct params', async function () {
332 await makeGetRequest({
333 url: server.url,
334 path,
335 token: server.accessToken,
336 query: {
337 isLocal: false,
338 search: 'toto',
339 searchAccount: 'toto',
340 searchVideo: 'toto'
341 },
342 statusCodeExpected: 200
343 })
344 })
345 })
346
299 after(async function () { 347 after(async function () {
300 await cleanupTests([ server ]) 348 await cleanupTests([ server ])
301 }) 349 })
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index aa2e1318a..94c966c9f 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -10,7 +10,6 @@ import {
10 checkLiveCleanup, 10 checkLiveCleanup,
11 checkLiveSegmentHash, 11 checkLiveSegmentHash,
12 checkResolutionsInMasterPlaylist, 12 checkResolutionsInMasterPlaylist,
13 checkSegmentHash,
14 cleanupTests, 13 cleanupTests,
15 createLive, 14 createLive,
16 doubleFollow, 15 doubleFollow,
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index d7b04373f..c90fd09fb 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -158,7 +158,7 @@ describe('Test multiple servers', function () {
158 }) 158 })
159 159
160 it('Should upload the video on server 2 and propagate on each server', async function () { 160 it('Should upload the video on server 2 and propagate on each server', async function () {
161 this.timeout(50000) 161 this.timeout(100000)
162 162
163 const user = { 163 const user = {
164 username: 'user1', 164 username: 'user1',
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index afb58e95a..141a80690 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -1,8 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 4import * as chai from 'chai'
5
6import { cleanupTests, testImage } from '../../../../shared/extra-utils' 6import { cleanupTests, testImage } from '../../../../shared/extra-utils'
7import { 7import {
8 createUser, 8 createUser,
@@ -18,9 +18,11 @@ import {
18 addVideoCommentReply, 18 addVideoCommentReply,
19 addVideoCommentThread, 19 addVideoCommentThread,
20 deleteVideoComment, 20 deleteVideoComment,
21 getAdminVideoComments,
21 getVideoCommentThreads, 22 getVideoCommentThreads,
22 getVideoThreadComments 23 getVideoThreadComments
23} from '../../../../shared/extra-utils/videos/video-comments' 24} from '../../../../shared/extra-utils/videos/video-comments'
25import { VideoComment, VideoCommentAdmin, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
24 26
25const expect = chai.expect 27const expect = chai.expect
26 28
@@ -59,186 +61,248 @@ describe('Test video comments', function () {
59 userAccessTokenServer1 = await getAccessToken(server.url, 'user1', 'password') 61 userAccessTokenServer1 = await getAccessToken(server.url, 'user1', 'password')
60 }) 62 })
61 63
62 it('Should not have threads on this video', async function () { 64 describe('User comments', function () {
63 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
64 65
65 expect(res.body.total).to.equal(0) 66 it('Should not have threads on this video', async function () {
66 expect(res.body.data).to.be.an('array') 67 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
67 expect(res.body.data).to.have.lengthOf(0)
68 })
69 68
70 it('Should create a thread in this video', async function () { 69 expect(res.body.total).to.equal(0)
71 const text = 'my super first comment' 70 expect(res.body.data).to.be.an('array')
72 71 expect(res.body.data).to.have.lengthOf(0)
73 const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, text) 72 })
74 const comment = res.body.comment
75
76 expect(comment.inReplyToCommentId).to.be.null
77 expect(comment.text).equal('my super first comment')
78 expect(comment.videoId).to.equal(videoId)
79 expect(comment.id).to.equal(comment.threadId)
80 expect(comment.account.name).to.equal('root')
81 expect(comment.account.host).to.equal('localhost:' + server.port)
82 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root')
83 expect(comment.totalReplies).to.equal(0)
84 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
85 expect(dateIsValid(comment.createdAt as string)).to.be.true
86 expect(dateIsValid(comment.updatedAt as string)).to.be.true
87 })
88 73
89 it('Should list threads of this video', async function () { 74 it('Should create a thread in this video', async function () {
90 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) 75 const text = 'my super first comment'
76
77 const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, text)
78 const comment = res.body.comment
79
80 expect(comment.inReplyToCommentId).to.be.null
81 expect(comment.text).equal('my super first comment')
82 expect(comment.videoId).to.equal(videoId)
83 expect(comment.id).to.equal(comment.threadId)
84 expect(comment.account.name).to.equal('root')
85 expect(comment.account.host).to.equal('localhost:' + server.port)
86 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root')
87 expect(comment.totalReplies).to.equal(0)
88 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
89 expect(dateIsValid(comment.createdAt as string)).to.be.true
90 expect(dateIsValid(comment.updatedAt as string)).to.be.true
91 })
91 92
92 expect(res.body.total).to.equal(1) 93 it('Should list threads of this video', async function () {
93 expect(res.body.data).to.be.an('array') 94 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
94 expect(res.body.data).to.have.lengthOf(1)
95 95
96 const comment: VideoComment = res.body.data[0] 96 expect(res.body.total).to.equal(1)
97 expect(comment.inReplyToCommentId).to.be.null 97 expect(res.body.data).to.be.an('array')
98 expect(comment.text).equal('my super first comment') 98 expect(res.body.data).to.have.lengthOf(1)
99 expect(comment.videoId).to.equal(videoId)
100 expect(comment.id).to.equal(comment.threadId)
101 expect(comment.account.name).to.equal('root')
102 expect(comment.account.host).to.equal('localhost:' + server.port)
103 99
104 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') 100 const comment: VideoComment = res.body.data[0]
101 expect(comment.inReplyToCommentId).to.be.null
102 expect(comment.text).equal('my super first comment')
103 expect(comment.videoId).to.equal(videoId)
104 expect(comment.id).to.equal(comment.threadId)
105 expect(comment.account.name).to.equal('root')
106 expect(comment.account.host).to.equal('localhost:' + server.port)
105 107
106 expect(comment.totalReplies).to.equal(0) 108 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
107 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
108 expect(dateIsValid(comment.createdAt as string)).to.be.true
109 expect(dateIsValid(comment.updatedAt as string)).to.be.true
110 109
111 threadId = comment.threadId 110 expect(comment.totalReplies).to.equal(0)
112 }) 111 expect(comment.totalRepliesFromVideoAuthor).to.equal(0)
112 expect(dateIsValid(comment.createdAt as string)).to.be.true
113 expect(dateIsValid(comment.updatedAt as string)).to.be.true
113 114
114 it('Should get all the thread created', async function () { 115 threadId = comment.threadId
115 const res = await getVideoThreadComments(server.url, videoUUID, threadId) 116 })
116 117
117 const rootComment = res.body.comment 118 it('Should get all the thread created', async function () {
118 expect(rootComment.inReplyToCommentId).to.be.null 119 const res = await getVideoThreadComments(server.url, videoUUID, threadId)
119 expect(rootComment.text).equal('my super first comment') 120
120 expect(rootComment.videoId).to.equal(videoId) 121 const rootComment = res.body.comment
121 expect(dateIsValid(rootComment.createdAt as string)).to.be.true 122 expect(rootComment.inReplyToCommentId).to.be.null
122 expect(dateIsValid(rootComment.updatedAt as string)).to.be.true 123 expect(rootComment.text).equal('my super first comment')
123 }) 124 expect(rootComment.videoId).to.equal(videoId)
125 expect(dateIsValid(rootComment.createdAt as string)).to.be.true
126 expect(dateIsValid(rootComment.updatedAt as string)).to.be.true
127 })
124 128
125 it('Should create multiple replies in this thread', async function () { 129 it('Should create multiple replies in this thread', async function () {
126 const text1 = 'my super answer to thread 1' 130 const text1 = 'my super answer to thread 1'
127 const childCommentRes = await addVideoCommentReply(server.url, server.accessToken, videoId, threadId, text1) 131 const childCommentRes = await addVideoCommentReply(server.url, server.accessToken, videoId, threadId, text1)
128 const childCommentId = childCommentRes.body.comment.id 132 const childCommentId = childCommentRes.body.comment.id
129 133
130 const text2 = 'my super answer to answer of thread 1' 134 const text2 = 'my super answer to answer of thread 1'
131 await addVideoCommentReply(server.url, server.accessToken, videoId, childCommentId, text2) 135 await addVideoCommentReply(server.url, server.accessToken, videoId, childCommentId, text2)
132 136
133 const text3 = 'my second answer to thread 1' 137 const text3 = 'my second answer to thread 1'
134 await addVideoCommentReply(server.url, server.accessToken, videoId, threadId, text3) 138 await addVideoCommentReply(server.url, server.accessToken, videoId, threadId, text3)
135 }) 139 })
136 140
137 it('Should get correctly the replies', async function () { 141 it('Should get correctly the replies', async function () {
138 const res = await getVideoThreadComments(server.url, videoUUID, threadId) 142 const res = await getVideoThreadComments(server.url, videoUUID, threadId)
139 143
140 const tree: VideoCommentThreadTree = res.body 144 const tree: VideoCommentThreadTree = res.body
141 expect(tree.comment.text).equal('my super first comment') 145 expect(tree.comment.text).equal('my super first comment')
142 expect(tree.children).to.have.lengthOf(2) 146 expect(tree.children).to.have.lengthOf(2)
143 147
144 const firstChild = tree.children[0] 148 const firstChild = tree.children[0]
145 expect(firstChild.comment.text).to.equal('my super answer to thread 1') 149 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
146 expect(firstChild.children).to.have.lengthOf(1) 150 expect(firstChild.children).to.have.lengthOf(1)
147 151
148 const childOfFirstChild = firstChild.children[0] 152 const childOfFirstChild = firstChild.children[0]
149 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') 153 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
150 expect(childOfFirstChild.children).to.have.lengthOf(0) 154 expect(childOfFirstChild.children).to.have.lengthOf(0)
151 155
152 const secondChild = tree.children[1] 156 const secondChild = tree.children[1]
153 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 157 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
154 expect(secondChild.children).to.have.lengthOf(0) 158 expect(secondChild.children).to.have.lengthOf(0)
155 159
156 replyToDeleteId = secondChild.comment.id 160 replyToDeleteId = secondChild.comment.id
157 }) 161 })
158 162
159 it('Should create other threads', async function () { 163 it('Should create other threads', async function () {
160 const text1 = 'super thread 2' 164 const text1 = 'super thread 2'
161 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text1) 165 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text1)
162 166
163 const text2 = 'super thread 3' 167 const text2 = 'super thread 3'
164 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text2) 168 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text2)
165 }) 169 })
166 170
167 it('Should list the threads', async function () { 171 it('Should list the threads', async function () {
168 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') 172 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
169 173
170 expect(res.body.total).to.equal(3) 174 expect(res.body.total).to.equal(3)
171 expect(res.body.data).to.be.an('array') 175 expect(res.body.data).to.be.an('array')
172 expect(res.body.data).to.have.lengthOf(3) 176 expect(res.body.data).to.have.lengthOf(3)
173 177
174 expect(res.body.data[0].text).to.equal('my super first comment') 178 expect(res.body.data[0].text).to.equal('my super first comment')
175 expect(res.body.data[0].totalReplies).to.equal(3) 179 expect(res.body.data[0].totalReplies).to.equal(3)
176 expect(res.body.data[1].text).to.equal('super thread 2') 180 expect(res.body.data[1].text).to.equal('super thread 2')
177 expect(res.body.data[1].totalReplies).to.equal(0) 181 expect(res.body.data[1].totalReplies).to.equal(0)
178 expect(res.body.data[2].text).to.equal('super thread 3') 182 expect(res.body.data[2].text).to.equal('super thread 3')
179 expect(res.body.data[2].totalReplies).to.equal(0) 183 expect(res.body.data[2].totalReplies).to.equal(0)
180 }) 184 })
181 185
182 it('Should delete a reply', async function () { 186 it('Should delete a reply', async function () {
183 await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId) 187 await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId)
184 188
185 const res = await getVideoThreadComments(server.url, videoUUID, threadId) 189 const res = await getVideoThreadComments(server.url, videoUUID, threadId)
186 190
187 const tree: VideoCommentThreadTree = res.body 191 const tree: VideoCommentThreadTree = res.body
188 expect(tree.comment.text).equal('my super first comment') 192 expect(tree.comment.text).equal('my super first comment')
189 expect(tree.children).to.have.lengthOf(2) 193 expect(tree.children).to.have.lengthOf(2)
190 194
191 const firstChild = tree.children[0] 195 const firstChild = tree.children[0]
192 expect(firstChild.comment.text).to.equal('my super answer to thread 1') 196 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
193 expect(firstChild.children).to.have.lengthOf(1) 197 expect(firstChild.children).to.have.lengthOf(1)
194 198
195 const childOfFirstChild = firstChild.children[0] 199 const childOfFirstChild = firstChild.children[0]
196 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') 200 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
197 expect(childOfFirstChild.children).to.have.lengthOf(0) 201 expect(childOfFirstChild.children).to.have.lengthOf(0)
198 202
199 const deletedChildOfFirstChild = tree.children[1] 203 const deletedChildOfFirstChild = tree.children[1]
200 expect(deletedChildOfFirstChild.comment.text).to.equal('') 204 expect(deletedChildOfFirstChild.comment.text).to.equal('')
201 expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true 205 expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true
202 expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null 206 expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null
203 expect(deletedChildOfFirstChild.comment.account).to.be.null 207 expect(deletedChildOfFirstChild.comment.account).to.be.null
204 expect(deletedChildOfFirstChild.children).to.have.lengthOf(0) 208 expect(deletedChildOfFirstChild.children).to.have.lengthOf(0)
205 }) 209 })
206 210
207 it('Should delete a complete thread', async function () { 211 it('Should delete a complete thread', async function () {
208 await deleteVideoComment(server.url, server.accessToken, videoId, threadId) 212 await deleteVideoComment(server.url, server.accessToken, videoId, threadId)
209 213
210 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') 214 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt')
211 expect(res.body.total).to.equal(3) 215 expect(res.body.total).to.equal(3)
212 expect(res.body.data).to.be.an('array') 216 expect(res.body.data).to.be.an('array')
213 expect(res.body.data).to.have.lengthOf(3) 217 expect(res.body.data).to.have.lengthOf(3)
214 218
215 expect(res.body.data[0].text).to.equal('') 219 expect(res.body.data[0].text).to.equal('')
216 expect(res.body.data[0].isDeleted).to.be.true 220 expect(res.body.data[0].isDeleted).to.be.true
217 expect(res.body.data[0].deletedAt).to.not.be.null 221 expect(res.body.data[0].deletedAt).to.not.be.null
218 expect(res.body.data[0].account).to.be.null 222 expect(res.body.data[0].account).to.be.null
219 expect(res.body.data[0].totalReplies).to.equal(3) 223 expect(res.body.data[0].totalReplies).to.equal(3)
220 expect(res.body.data[1].text).to.equal('super thread 2') 224 expect(res.body.data[1].text).to.equal('super thread 2')
221 expect(res.body.data[1].totalReplies).to.equal(0) 225 expect(res.body.data[1].totalReplies).to.equal(0)
222 expect(res.body.data[2].text).to.equal('super thread 3') 226 expect(res.body.data[2].text).to.equal('super thread 3')
223 expect(res.body.data[2].totalReplies).to.equal(0) 227 expect(res.body.data[2].totalReplies).to.equal(0)
228 })
229
230 it('Should count replies from the video author correctly', async function () {
231 const text = 'my super first comment'
232 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text)
233 let res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
234 const comment: VideoComment = res.body.data[0]
235 const threadId2 = comment.threadId
236
237 const text2 = 'a first answer to thread 4 by a third party'
238 await addVideoCommentReply(server.url, userAccessTokenServer1, videoId, threadId2, text2)
239
240 const text3 = 'my second answer to thread 4'
241 await addVideoCommentReply(server.url, server.accessToken, videoId, threadId2, text3)
242
243 res = await getVideoThreadComments(server.url, videoUUID, threadId2)
244 const tree: VideoCommentThreadTree = res.body
245 expect(tree.comment.totalReplies).to.equal(tree.comment.totalRepliesFromVideoAuthor + 1)
246 })
224 }) 247 })
225 248
226 it('Should count replies from the video author correctly', async function () { 249 describe('All instance comments', function () {
227 const text = 'my super first comment' 250 async function getComments (options: any = {}) {
228 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text) 251 const res = await getAdminVideoComments(Object.assign({
229 let res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) 252 url: server.url,
230 const comment: VideoComment = res.body.data[0] 253 token: server.accessToken,
231 const threadId2 = comment.threadId 254 start: 0,
255 count: 10
256 }, options))
257
258 return { comments: res.body.data as VideoCommentAdmin[], total: res.body.total as number }
259 }
260
261 it('Should list instance comments as admin', async function () {
262 const { comments } = await getComments({ start: 0, count: 1 })
263
264 expect(comments[0].text).to.equal('my second answer to thread 4')
265 })
266
267 it('Should filter instance comments by isLocal', async function () {
268 const { total, comments } = await getComments({ isLocal: false })
232 269
233 const text2 = 'a first answer to thread 4 by a third party' 270 expect(comments).to.have.lengthOf(0)
234 await addVideoCommentReply(server.url, userAccessTokenServer1, videoId, threadId2, text2) 271 expect(total).to.equal(0)
272 })
273
274 it('Should search instance comments by account', async function () {
275 const { total, comments } = await getComments({ searchAccount: 'user' })
276
277 expect(comments).to.have.lengthOf(1)
278 expect(total).to.equal(1)
279
280 expect(comments[0].text).to.equal('a first answer to thread 4 by a third party')
281 })
282
283 it('Should search instance comments by video', async function () {
284 {
285 const { total, comments } = await getComments({ searchVideo: 'video' })
235 286
236 const text3 = 'my second answer to thread 4' 287 expect(comments).to.have.lengthOf(7)
237 await addVideoCommentReply(server.url, server.accessToken, videoId, threadId2, text3) 288 expect(total).to.equal(7)
289 }
238 290
239 res = await getVideoThreadComments(server.url, videoUUID, threadId2) 291 {
240 const tree: VideoCommentThreadTree = res.body 292 const { total, comments } = await getComments({ searchVideo: 'hello' })
241 expect(tree.comment.totalReplies).to.equal(tree.comment.totalRepliesFromVideoAuthor + 1) 293
294 expect(comments).to.have.lengthOf(0)
295 expect(total).to.equal(0)
296 }
297 })
298
299 it('Should search instance comments', async function () {
300 const { total, comments } = await getComments({ search: 'super thread 3' })
301
302 expect(comments).to.have.lengthOf(1)
303 expect(total).to.equal(1)
304 expect(comments[0].text).to.equal('super thread 3')
305 })
242 }) 306 })
243 307
244 after(async function () { 308 after(async function () {
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 0bfb5bcd4..b194665ba 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -628,7 +628,7 @@ describe('Test video playlists', function () {
628 let video3: string 628 let video3: string
629 629
630 before(async function () { 630 before(async function () {
631 this.timeout(30000) 631 this.timeout(60000)
632 632
633 groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ] 633 groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ]
634 groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ] 634 groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ]
@@ -656,6 +656,8 @@ describe('Test video playlists', function () {
656 video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid 656 video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid
657 video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid 657 video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid
658 658
659 await waitJobs(servers)
660
659 await addVideo({ videoId: video1, startTimestamp: 15, stopTimestamp: 28 }) 661 await addVideo({ videoId: video1, startTimestamp: 15, stopTimestamp: 28 })
660 await addVideo({ videoId: video2, startTimestamp: 35 }) 662 await addVideo({ videoId: video2, startTimestamp: 35 })
661 await addVideo({ videoId: video3 }) 663 await addVideo({ videoId: video3 })
diff --git a/server/types/models/video/video-comment.ts b/server/types/models/video/video-comment.ts
index f1c50c753..83479e7b2 100644
--- a/server/types/models/video/video-comment.ts
+++ b/server/types/models/video/video-comment.ts
@@ -1,7 +1,7 @@
1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith, PickWithOpt } from '@shared/core-utils' 1import { PickWith, PickWithOpt } from '@shared/core-utils'
2import { VideoCommentModel } from '../../../models/video/video-comment'
3import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account' 3import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account'
4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' 4import { MVideo, MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video'
5 5
6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M> 6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
7 7
@@ -59,6 +59,11 @@ export type MCommentFormattable =
59 MCommentTotalReplies & 59 MCommentTotalReplies &
60 Use<'Account', MAccountFormattable> 60 Use<'Account', MAccountFormattable>
61 61
62export type MCommentAdminFormattable =
63 MComment &
64 Use<'Account', MAccountFormattable> &
65 Use<'Video', MVideo>
66
62export type MCommentAP = 67export type MCommentAP =
63 MComment & 68 MComment &
64 Use<'Account', MAccountUrl> & 69 Use<'Account', MAccountUrl> &