diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-15 16:43:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-16 16:41:36 +0200 |
commit | 65b21c961c69c4a63c7c0c34be3d6d034a1176c7 (patch) | |
tree | 35ec4a16c90a1de99b2865fbabb368b683ca6c87 /server | |
parent | b44164bb567fe7c9f65f1ac2908d44990a8ccc8e (diff) | |
download | PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.tar.gz PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.tar.zst PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.zip |
Add ability to mute a user/instance by server in client
Diffstat (limited to 'server')
-rw-r--r-- | server/models/video/video-comment.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 6 | ||||
-rw-r--r-- | server/tests/api/users/blocklist.ts | 31 |
3 files changed, 27 insertions, 14 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 08c6b3ff0..dd6d08139 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -294,7 +294,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
294 | static async listThreadsForApi (videoId: number, start: number, count: number, sort: string, user?: UserModel) { | 294 | static async listThreadsForApi (videoId: number, start: number, count: number, sort: string, user?: UserModel) { |
295 | const serverActor = await getServerActor() | 295 | const serverActor = await getServerActor() |
296 | const serverAccountId = serverActor.Account.id | 296 | const serverAccountId = serverActor.Account.id |
297 | const userAccountId = user.Account.id | 297 | const userAccountId = user ? user.Account.id : undefined |
298 | 298 | ||
299 | const query = { | 299 | const query = { |
300 | offset: start, | 300 | offset: start, |
@@ -330,7 +330,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
330 | static async listThreadCommentsForApi (videoId: number, threadId: number, user?: UserModel) { | 330 | static async listThreadCommentsForApi (videoId: number, threadId: number, user?: UserModel) { |
331 | const serverActor = await getServerActor() | 331 | const serverActor = await getServerActor() |
332 | const serverAccountId = serverActor.Account.id | 332 | const serverAccountId = serverActor.Account.id |
333 | const userAccountId = user.Account.id | 333 | const userAccountId = user ? user.Account.id : undefined |
334 | 334 | ||
335 | const query = { | 335 | const query = { |
336 | order: [ [ 'createdAt', 'ASC' ], [ 'updatedAt', 'ASC' ] ], | 336 | order: [ [ 'createdAt', 'ASC' ], [ 'updatedAt', 'ASC' ] ], |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index eab99cba7..6c183933b 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1255,9 +1255,11 @@ export class VideoModel extends Model<VideoModel> { | |||
1255 | 1255 | ||
1256 | // threshold corresponds to how many video the field should have to be returned | 1256 | // threshold corresponds to how many video the field should have to be returned |
1257 | static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) { | 1257 | static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) { |
1258 | const actorId = (await getServerActor()).id | 1258 | const serverActor = await getServerActor() |
1259 | const actorId = serverActor.id | ||
1259 | 1260 | ||
1260 | const scopeOptions = { | 1261 | const scopeOptions: AvailableForListIDsOptions = { |
1262 | serverAccountId: serverActor.Account.id, | ||
1261 | actorId, | 1263 | actorId, |
1262 | includeLocalVideos: true | 1264 | includeLocalVideos: true |
1263 | } | 1265 | } |
diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts index 99fe04b8c..eed4b9f3e 100644 --- a/server/tests/api/users/blocklist.ts +++ b/server/tests/api/users/blocklist.ts | |||
@@ -14,7 +14,7 @@ import { | |||
14 | userLogin | 14 | userLogin |
15 | } from '../../utils/index' | 15 | } from '../../utils/index' |
16 | import { setAccessTokensToServers } from '../../utils/users/login' | 16 | import { setAccessTokensToServers } from '../../utils/users/login' |
17 | import { getVideosListWithToken } from '../../utils/videos/videos' | 17 | import { getVideosListWithToken, getVideosList } from '../../utils/videos/videos' |
18 | import { | 18 | import { |
19 | addVideoCommentReply, | 19 | addVideoCommentReply, |
20 | addVideoCommentThread, | 20 | addVideoCommentThread, |
@@ -41,9 +41,17 @@ import { | |||
41 | const expect = chai.expect | 41 | const expect = chai.expect |
42 | 42 | ||
43 | async function checkAllVideos (url: string, token: string) { | 43 | async function checkAllVideos (url: string, token: string) { |
44 | const res = await getVideosListWithToken(url, token) | 44 | { |
45 | const res = await getVideosListWithToken(url, token) | ||
45 | 46 | ||
46 | expect(res.body.data).to.have.lengthOf(4) | 47 | expect(res.body.data).to.have.lengthOf(4) |
48 | } | ||
49 | |||
50 | { | ||
51 | const res = await getVideosList(url) | ||
52 | |||
53 | expect(res.body.data).to.have.lengthOf(4) | ||
54 | } | ||
47 | } | 55 | } |
48 | 56 | ||
49 | async function checkAllComments (url: string, token: string, videoUUID: string) { | 57 | async function checkAllComments (url: string, token: string, videoUUID: string) { |
@@ -444,16 +452,19 @@ describe('Test blocklist', function () { | |||
444 | 452 | ||
445 | it('Should hide its videos', async function () { | 453 | it('Should hide its videos', async function () { |
446 | for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) { | 454 | for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) { |
447 | const res = await getVideosListWithToken(servers[ 0 ].url, token) | 455 | const res1 = await getVideosList(servers[ 0 ].url) |
456 | const res2 = await getVideosListWithToken(servers[ 0 ].url, token) | ||
448 | 457 | ||
449 | const videos: Video[] = res.body.data | 458 | for (const res of [ res1, res2 ]) { |
450 | expect(videos).to.have.lengthOf(2) | 459 | const videos: Video[] = res.body.data |
460 | expect(videos).to.have.lengthOf(2) | ||
451 | 461 | ||
452 | const v1 = videos.find(v => v.name === 'video user 2') | 462 | const v1 = videos.find(v => v.name === 'video user 2') |
453 | const v2 = videos.find(v => v.name === 'video server 2') | 463 | const v2 = videos.find(v => v.name === 'video server 2') |
454 | 464 | ||
455 | expect(v1).to.be.undefined | 465 | expect(v1).to.be.undefined |
456 | expect(v2).to.be.undefined | 466 | expect(v2).to.be.undefined |
467 | } | ||
457 | } | 468 | } |
458 | }) | 469 | }) |
459 | 470 | ||