ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to list comments on local videos
Chocobozzz0e6cd1c00f71
diff --git a/client/src/app/+admin/overview/comments/video-comment-list.component.ts b/client/src/app/+admin/overview/comments/video-comment-list.component.tsindex f01a1629b6..cfe40b92a3 100644--- a/client/src/app/+admin/overview/comments/video-comment-list.component.ts+++ b/client/src/app/+admin/overview/comments/video-comment-list.component.ts@@ -54,6 +54,10 @@ export class VideoCommentListComponent extends RestTable implements OnInit {{value: 'local:false',label: $localize`Remote comments`+ },+ {+ value: 'localVideo:true',+ label: $localize`Comments on local videos`}]}diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.tsindex 8cd94643a4..8d2deedf7f 100644--- a/client/src/app/shared/shared-video-comment/video-comment.service.ts+++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts@@ -190,6 +190,10 @@ export class VideoCommentService {prefix: 'local:',isBoolean: true},+ onLocalVideo: {+ prefix: 'localVideo:',+ isBoolean: true+ },searchAccount: { prefix: 'account:' },searchVideo: { prefix: 'video:' }diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.tsindex 47fa2f2e20..44d64776c6 100644--- a/server/controllers/api/videos/comment.ts+++ b/server/controllers/api/videos/comment.ts@@ -91,6 +91,7 @@ async function listComments (req: express.Request, res: express.Response) {sort: req.query.sort,isLocal: req.query.isLocal,+ onLocalVideo: req.query.onLocalVideo,search: req.query.search,searchAccount: req.query.searchAccount,searchVideo: req.query.searchVideodiff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.tsindex b22a4e3b79..68f41e50e5 100644--- a/server/middlewares/validators/videos/video-comments.ts+++ b/server/middlewares/validators/videos/video-comments.ts@@ -24,6 +24,12 @@ const listVideoCommentsValidator = [.custom(isBooleanValid).withMessage('Should have a valid is local boolean'),+ query('onLocalVideo')+ .optional()+ .customSanitizer(toBooleanOrNull)+ .custom(isBooleanValid)+ .withMessage('Should have a valid is on local video boolean'),+query('search').optional().custom(exists).withMessage('Should have a valid search'),diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.tsindex 6c5a764bf2..1195e47e9d 100644--- a/server/models/video/video-comment.ts+++ b/server/models/video/video-comment.ts@@ -14,6 +14,7 @@ import {Table,UpdatedAt} from 'sequelize-typescript'+import { exists } from '@server/helpers/custom-validators/misc'import { getServerActor } from '@server/models/application/application'import { MAccount, MAccountId, MUserAccountId } from '@server/types/models'import { VideoPrivacy } from '@shared/models'@@ -312,12 +313,13 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoCommentcount: numbersort: string+ onLocalVideo?: booleanisLocal?: booleansearch?: stringsearchAccount?: stringsearchVideo?: string}) {- const { start, count, sort, isLocal, search, searchAccount, searchVideo } = parameters+ const { start, count, sort, isLocal, search, searchAccount, searchVideo, onLocalVideo } = parametersconst where: WhereOptions = {deletedAt: null@@ -363,6 +365,10 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoCommentObject.assign(whereVideo, searchAttribute(searchVideo, 'name'))}+ if (exists(onLocalVideo)) {+ Object.assign(whereVideo, { remote: !onLocalVideo })+ }+const getQuery = (forCount: boolean) => {return {offset: start,diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.tsindex 1488ce2b5a..5ab401aa40 100644--- a/server/tests/api/videos/video-comments.ts+++ b/server/tests/api/videos/video-comments.ts@@ -254,6 +254,22 @@ describe('Test video comments', function () {expect(total).to.equal(0)})+ it('Should filter instance comments by onLocalVideo', async function () {+ {+ const { total, data } = await command.listForAdmin({ onLocalVideo: false })++ expect(data).to.have.lengthOf(0)+ expect(total).to.equal(0)+ }++ {+ const { total, data } = await command.listForAdmin({ onLocalVideo: true })++ expect(data).to.not.have.lengthOf(0)+ expect(total).to.not.equal(0)+ }+ })+it('Should search instance comments by account', async function () {const { total, data } = await command.listForAdmin({ searchAccount: 'user' })diff --git a/shared/server-commands/videos/comments-command.ts b/shared/server-commands/videos/comments-command.tsindex f0d163a077..156cf452f1 100644--- a/shared/server-commands/videos/comments-command.ts+++ b/shared/server-commands/videos/comments-command.ts@@ -14,6 +14,7 @@ export class CommentsCommand extends AbstractCommand {count?: numbersort?: stringisLocal?: boolean+ onLocalVideo?: booleansearch?: stringsearchAccount?: stringsearchVideo?: string@@ -21,7 +22,7 @@ export class CommentsCommand extends AbstractCommand {const { sort = '-createdAt' } = optionsconst path = '/api/v1/videos/comments'- const query = { sort, ...pick(options, [ 'start', 'count', 'isLocal', 'search', 'searchAccount', 'searchVideo' ]) }+ const query = { sort, ...pick(options, [ 'start', 'count', 'isLocal', 'onLocalVideo', 'search', 'searchAccount', 'searchVideo' ]) }return this.getRequestBody<ResultList<VideoComment>>({...options,