diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-06 14:12:12 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-06 14:12:12 +0200 |
commit | 1df8a4d79a491d2ad5bdd9329f37e52cba21238c (patch) | |
tree | 4d678958352f1d6044c2ef9fe052f66d323a01b0 | |
parent | f375bb3db401e42b4317545a7e40dcfda692604d (diff) | |
download | PeerTube-1df8a4d79a491d2ad5bdd9329f37e52cba21238c.tar.gz PeerTube-1df8a4d79a491d2ad5bdd9329f37e52cba21238c.tar.zst PeerTube-1df8a4d79a491d2ad5bdd9329f37e52cba21238c.zip |
Fix comments feed with musted accounts
-rw-r--r-- | server/models/video/video-comment.ts | 11 | ||||
-rw-r--r-- | server/tests/feeds/feeds.ts | 12 |
2 files changed, 21 insertions, 2 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index b7ed6240e..6d60271e6 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -381,13 +381,20 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
381 | return VideoCommentModel.findAndCountAll<MComment>(query) | 381 | return VideoCommentModel.findAndCountAll<MComment>(query) |
382 | } | 382 | } |
383 | 383 | ||
384 | static listForFeed (start: number, count: number, videoId?: number): Bluebird<MCommentOwnerVideoFeed[]> { | 384 | static async listForFeed (start: number, count: number, videoId?: number): Promise<MCommentOwnerVideoFeed[]> { |
385 | const serverActor = await getServerActor() | ||
386 | |||
385 | const query = { | 387 | const query = { |
386 | order: [ [ 'createdAt', 'DESC' ] ] as Order, | 388 | order: [ [ 'createdAt', 'DESC' ] ] as Order, |
387 | offset: start, | 389 | offset: start, |
388 | limit: count, | 390 | limit: count, |
389 | where: { | 391 | where: { |
390 | deletedAt: null | 392 | deletedAt: null, |
393 | accountId: { | ||
394 | [Op.notIn]: Sequelize.literal( | ||
395 | '(' + buildBlockedAccountSQL(serverActor.Account.id) + ')' | ||
396 | ) | ||
397 | } | ||
391 | }, | 398 | }, |
392 | include: [ | 399 | include: [ |
393 | { | 400 | { |
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index d978123cf..7fac921a3 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts | |||
@@ -20,6 +20,7 @@ import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video- | |||
20 | import { waitJobs } from '../../../shared/extra-utils/server/jobs' | 20 | import { waitJobs } from '../../../shared/extra-utils/server/jobs' |
21 | import { User } from '../../../shared/models/users' | 21 | import { User } from '../../../shared/models/users' |
22 | import { VideoPrivacy } from '@shared/models' | 22 | import { VideoPrivacy } from '@shared/models' |
23 | import { addAccountToServerBlocklist } from '@shared/extra-utils/users/blocklist' | ||
23 | 24 | ||
24 | chai.use(require('chai-xml')) | 25 | chai.use(require('chai-xml')) |
25 | chai.use(require('chai-json-schema')) | 26 | chai.use(require('chai-json-schema')) |
@@ -216,6 +217,17 @@ describe('Test syndication feeds', () => { | |||
216 | expect(jsonObj.items[1].html_content).to.equal('super comment 1') | 217 | expect(jsonObj.items[1].html_content).to.equal('super comment 1') |
217 | } | 218 | } |
218 | }) | 219 | }) |
220 | |||
221 | it('Should not list comments from muted accounts or instances', async function () { | ||
222 | await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, 'root@localhost:' + servers[0].port) | ||
223 | |||
224 | { | ||
225 | const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 2 }) | ||
226 | const jsonObj = JSON.parse(json.text) | ||
227 | expect(jsonObj.items.length).to.be.equal(0) | ||
228 | } | ||
229 | |||
230 | }) | ||
219 | }) | 231 | }) |
220 | 232 | ||
221 | after(async function () { | 233 | after(async function () { |