From 5baee5fca418487e72ddcd6419d31bca8659b668 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 2 Jun 2020 20:50:42 +0200 Subject: rename blacklist to block/blocklist, merge block and auto-block views - also replace whitelist with allowlist - add advanced filters for video-block-list view - move icons in video-block-list and video-abuse-list to left side for visibility - add robot icon to depict automated nature of a block in video-block-list resolves #2790 --- server/controllers/api/videos/blacklist.ts | 8 ++++---- server/helpers/custom-validators/video-blacklist.ts | 4 ++-- .../migrations/0350-video-blacklist-type.ts | 4 ++-- server/lib/notifier.ts | 8 ++++---- server/lib/video-blacklist.ts | 10 +++++----- server/models/account/user.ts | 4 ++-- server/models/video/video-blacklist.ts | 8 ++++---- server/tests/api/check-params/users.ts | 2 +- server/tests/api/check-params/video-blacklist.ts | 4 ++-- server/tests/api/users/users.ts | 4 ++-- server/tests/api/videos/video-blacklist.ts | 20 ++++++++++---------- 11 files changed, 38 insertions(+), 38 deletions(-) (limited to 'server') diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 3b25ceea2..2c6948923 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -23,14 +23,14 @@ const blacklistRouter = express.Router() blacklistRouter.post('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), asyncMiddleware(videosBlacklistAddValidator), asyncMiddleware(addVideoToBlacklistController) ) blacklistRouter.get('/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), paginationValidator, blacklistSortValidator, setBlacklistSort, @@ -41,14 +41,14 @@ blacklistRouter.get('/blacklist', blacklistRouter.put('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), asyncMiddleware(videosBlacklistUpdateValidator), asyncMiddleware(updateVideoBlacklistController) ) blacklistRouter.delete('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), asyncMiddleware(videosBlacklistRemoveValidator), asyncMiddleware(removeVideoFromBlacklistController) ) diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index 17cb3b00b..de6726b8f 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts @@ -1,7 +1,7 @@ import validator from 'validator' import { exists } from './misc' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { VideoBlacklistType } from '../../../shared/models/videos' +import { VideoBlockType } from '../../../shared/models/videos' const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST @@ -10,7 +10,7 @@ function isVideoBlacklistReasonValid (value: string) { } function isVideoBlacklistTypeValid (value: any) { - return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined + return exists(value) && validator.isInt('' + value) && VideoBlockType[value] !== undefined } // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0350-video-blacklist-type.ts b/server/initializers/migrations/0350-video-blacklist-type.ts index f79ae5ec7..22c82e431 100644 --- a/server/initializers/migrations/0350-video-blacklist-type.ts +++ b/server/initializers/migrations/0350-video-blacklist-type.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { VideoBlacklistType } from '../../../shared/models/videos' +import { VideoBlockType } from '../../../shared/models/videos' async function up (utils: { transaction: Sequelize.Transaction @@ -18,7 +18,7 @@ async function up (utils: { } { - const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlacklistType.MANUAL + const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlockType.MANUAL await utils.sequelize.query(query) } diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 89f91e031..3e90bb57e 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts @@ -387,7 +387,7 @@ class Notifier { } private async notifyModeratorsOfVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo) { - const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_BLACKLIST) + const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_BLOCKS) if (moderators.length === 0) return logger.info('Notifying %s moderators of video auto-blacklist %s.', moderators.length, videoBlacklist.Video.url) @@ -398,7 +398,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS, + type: UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS, userId: user.id, videoBlacklistId: videoBlacklist.id }) @@ -426,7 +426,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.BLACKLIST_ON_MY_VIDEO, + type: UserNotificationType.BLOCK_ON_MY_VIDEO, userId: user.id, videoBlacklistId: videoBlacklist.id }) @@ -454,7 +454,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.UNBLACKLIST_ON_MY_VIDEO, + type: UserNotificationType.UNBLOCK_ON_MY_VIDEO, userId: user.id, videoId: video.id }) diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index bd60c6201..f1657e8f1 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts @@ -8,7 +8,7 @@ import { MVideoFullLight, MVideoWithBlacklistLight } from '@server/typings/models' -import { UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models' +import { UserRight, VideoBlacklistCreate, VideoBlockType } from '../../shared/models' import { UserAdminFlag } from '../../shared/models/users/user-flag.model' import { logger } from '../helpers/logger' import { CONFIG } from '../initializers/config' @@ -39,7 +39,7 @@ async function autoBlacklistVideoIfNeeded (parameters: { videoId: video.id, unfederated: true, reason: 'Auto-blacklisted. Moderator review required.', - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED } const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate({ where: { @@ -64,7 +64,7 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video videoId: videoInstance.id, unfederated: options.unfederate === true, reason: options.reason, - type: VideoBlacklistType.MANUAL + type: VideoBlockType.MANUAL } ) blacklist.Video = videoInstance @@ -94,7 +94,7 @@ async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoF Notifier.Instance.notifyOnVideoUnblacklist(video) - if (videoBlacklistType === VideoBlacklistType.AUTO_BEFORE_PUBLISHED) { + if (videoBlacklistType === VideoBlockType.AUTO_BEFORE_PUBLISHED) { Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(video) // Delete on object so new video notifications will send @@ -126,7 +126,7 @@ function autoBlacklistNeeded (parameters: { if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED || !user) return false if (isRemote || isNew === false) return false - if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST)) return false + if (user.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK)) return false return true } diff --git a/server/models/account/user.ts b/server/models/account/user.ts index fbd3080c6..4ea175583 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -739,11 +739,11 @@ export class UserModel extends Model { const videoUserId = video.VideoChannel.Account.userId if (video.isBlacklisted()) { - return videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) + return videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) } if (video.privacy === VideoPrivacy.PRIVATE) { - return video.VideoChannel && videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) + return video.VideoChannel && videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) } if (video.privacy === VideoPrivacy.INTERNAL) return true diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 8cbfe362e..70a6ecb03 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts @@ -3,7 +3,7 @@ import { getBlacklistSort, SortType, throwIfNotValid, searchAttribute } from '.. import { VideoModel } from './video' import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' -import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' +import { VideoBlocklist, VideoBlockType } from '../../../shared/models/videos' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { FindOptions } from 'sequelize' import { ThumbnailModel } from './thumbnail' @@ -34,7 +34,7 @@ export class VideoBlacklistModel extends Model { @Default(null) @Is('VideoBlacklistType', value => throwIfNotValid(value, isVideoBlacklistTypeValid, 'type')) @Column - type: VideoBlacklistType + type: VideoBlockType @CreatedAt createdAt: Date @@ -59,7 +59,7 @@ export class VideoBlacklistModel extends Model { count: number sort: SortType search?: string - type?: VideoBlacklistType + type?: VideoBlockType }) { const { start, count, sort, search, type } = parameters @@ -119,7 +119,7 @@ export class VideoBlacklistModel extends Model { return VideoBlacklistModel.findOne(query) } - toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlacklist { + toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlocklist { return { id: this.id, createdAt: this.createdAt, diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 6e737af15..94d47408a 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -188,7 +188,7 @@ describe('Test users API validators', function () { videoQuota: -1, videoQuotaDaily: -1, role: UserRole.USER, - adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK } it('Should fail with a too small username', async function () { diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 145f43980..b96c26989 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts @@ -24,7 +24,7 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { VideoBlacklistType, VideoDetails } from '../../../../shared/models/videos' +import { VideoBlockType, VideoDetails } from '../../../../shared/models/videos' import { expect } from 'chai' describe('Test video blacklist API validators', function () { @@ -243,7 +243,7 @@ describe('Test video blacklist API validators', function () { }) it('Should succeed with the correct parameters', async function () { - await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL }) + await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlockType.MANUAL }) }) }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c0cbce360..af5a5fd25 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -265,7 +265,7 @@ describe('Test users', function () { username: user.username, password: user.password, videoQuota: 2 * 1024 * 1024, - adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK }) }) @@ -292,7 +292,7 @@ describe('Test users', function () { } expect(userMe.adminFlags).to.be.undefined - expect(userGet.adminFlags).to.equal(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST) + expect(userGet.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK) expect(userMe.specialPlaylists).to.have.lengthOf(1) expect(userMe.specialPlaylists[0].type).to.equal(VideoPlaylistType.WATCH_LATER) diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index 67bc0114c..6e15893f3 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts @@ -25,7 +25,7 @@ import { } from '../../../../shared/extra-utils/index' import { doubleFollow } from '../../../../shared/extra-utils/server/follows' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' +import { VideoBlocklist, VideoBlockType } from '../../../../shared/models/videos' import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' import { User, UserRole } from '../../../../shared/models/users' import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' @@ -127,7 +127,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlacklistType.MANUAL + type: VideoBlockType.MANUAL }) expect(res.body.total).to.equal(2) @@ -141,7 +141,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(0) @@ -219,7 +219,7 @@ describe('Test video blacklist', function () { }) describe('When removing a blacklisted video', function () { - let videoToRemove: VideoBlacklist + let videoToRemove: VideoBlocklist let blacklist = [] it('Should not have any video in videos list on server 1', async function () { @@ -328,7 +328,7 @@ describe('Test video blacklist', function () { it('Should have the correct video blacklist unfederate attribute', async function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) - const blacklistedVideos: VideoBlacklist[] = res.body.data + const blacklistedVideos: VideoBlocklist[] = res.body.data const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID) @@ -396,7 +396,7 @@ describe('Test video blacklist', function () { url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, - adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST, + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK, password: user.password, role: UserRole.USER }) @@ -413,7 +413,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(1) @@ -434,7 +434,7 @@ describe('Test video blacklist', function () { url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt', - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(2) @@ -453,7 +453,7 @@ describe('Test video blacklist', function () { url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt', - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(3) @@ -466,7 +466,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED + type: VideoBlockType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(3) -- cgit v1.2.3 From 3487330d308166afb542cbacae0475693c0b059e Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 9 Jun 2020 16:07:10 +0200 Subject: preserve original variable names server-side --- server/controllers/api/videos/blacklist.ts | 8 ++++---- server/helpers/custom-validators/video-blacklist.ts | 4 ++-- .../migrations/0350-video-blacklist-type.ts | 4 ++-- server/lib/notifier.ts | 8 ++++---- server/lib/video-blacklist.ts | 10 +++++----- server/models/account/user.ts | 4 ++-- server/models/video/video-blacklist.ts | 8 ++++---- server/tests/api/check-params/users.ts | 2 +- server/tests/api/check-params/video-blacklist.ts | 4 ++-- server/tests/api/users/users.ts | 4 ++-- server/tests/api/videos/video-blacklist.ts | 20 ++++++++++---------- 11 files changed, 38 insertions(+), 38 deletions(-) (limited to 'server') diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 2c6948923..3b25ceea2 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -23,14 +23,14 @@ const blacklistRouter = express.Router() blacklistRouter.post('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), asyncMiddleware(videosBlacklistAddValidator), asyncMiddleware(addVideoToBlacklistController) ) blacklistRouter.get('/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), paginationValidator, blacklistSortValidator, setBlacklistSort, @@ -41,14 +41,14 @@ blacklistRouter.get('/blacklist', blacklistRouter.put('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), asyncMiddleware(videosBlacklistUpdateValidator), asyncMiddleware(updateVideoBlacklistController) ) blacklistRouter.delete('/:videoId/blacklist', authenticate, - ensureUserHasRight(UserRight.MANAGE_VIDEO_BLOCKS), + ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), asyncMiddleware(videosBlacklistRemoveValidator), asyncMiddleware(removeVideoFromBlacklistController) ) diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index de6726b8f..17cb3b00b 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts @@ -1,7 +1,7 @@ import validator from 'validator' import { exists } from './misc' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { VideoBlockType } from '../../../shared/models/videos' +import { VideoBlacklistType } from '../../../shared/models/videos' const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST @@ -10,7 +10,7 @@ function isVideoBlacklistReasonValid (value: string) { } function isVideoBlacklistTypeValid (value: any) { - return exists(value) && validator.isInt('' + value) && VideoBlockType[value] !== undefined + return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined } // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0350-video-blacklist-type.ts b/server/initializers/migrations/0350-video-blacklist-type.ts index 22c82e431..f79ae5ec7 100644 --- a/server/initializers/migrations/0350-video-blacklist-type.ts +++ b/server/initializers/migrations/0350-video-blacklist-type.ts @@ -1,5 +1,5 @@ import * as Sequelize from 'sequelize' -import { VideoBlockType } from '../../../shared/models/videos' +import { VideoBlacklistType } from '../../../shared/models/videos' async function up (utils: { transaction: Sequelize.Transaction @@ -18,7 +18,7 @@ async function up (utils: { } { - const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlockType.MANUAL + const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlacklistType.MANUAL await utils.sequelize.query(query) } diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 3e90bb57e..89f91e031 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts @@ -387,7 +387,7 @@ class Notifier { } private async notifyModeratorsOfVideoAutoBlacklist (videoBlacklist: MVideoBlacklistLightVideo) { - const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_BLOCKS) + const moderators = await UserModel.listWithRight(UserRight.MANAGE_VIDEO_BLACKLIST) if (moderators.length === 0) return logger.info('Notifying %s moderators of video auto-blacklist %s.', moderators.length, videoBlacklist.Video.url) @@ -398,7 +398,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS, + type: UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS, userId: user.id, videoBlacklistId: videoBlacklist.id }) @@ -426,7 +426,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.BLOCK_ON_MY_VIDEO, + type: UserNotificationType.BLACKLIST_ON_MY_VIDEO, userId: user.id, videoBlacklistId: videoBlacklist.id }) @@ -454,7 +454,7 @@ class Notifier { async function notificationCreator (user: MUserWithNotificationSetting) { const notification = await UserNotificationModel.create({ - type: UserNotificationType.UNBLOCK_ON_MY_VIDEO, + type: UserNotificationType.UNBLACKLIST_ON_MY_VIDEO, userId: user.id, videoId: video.id }) diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index f1657e8f1..1ee92d22c 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts @@ -8,7 +8,7 @@ import { MVideoFullLight, MVideoWithBlacklistLight } from '@server/typings/models' -import { UserRight, VideoBlacklistCreate, VideoBlockType } from '../../shared/models' +import { UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models' import { UserAdminFlag } from '../../shared/models/users/user-flag.model' import { logger } from '../helpers/logger' import { CONFIG } from '../initializers/config' @@ -39,7 +39,7 @@ async function autoBlacklistVideoIfNeeded (parameters: { videoId: video.id, unfederated: true, reason: 'Auto-blacklisted. Moderator review required.', - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED } const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate({ where: { @@ -64,7 +64,7 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video videoId: videoInstance.id, unfederated: options.unfederate === true, reason: options.reason, - type: VideoBlockType.MANUAL + type: VideoBlacklistType.MANUAL } ) blacklist.Video = videoInstance @@ -94,7 +94,7 @@ async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoF Notifier.Instance.notifyOnVideoUnblacklist(video) - if (videoBlacklistType === VideoBlockType.AUTO_BEFORE_PUBLISHED) { + if (videoBlacklistType === VideoBlacklistType.AUTO_BEFORE_PUBLISHED) { Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(video) // Delete on object so new video notifications will send @@ -126,7 +126,7 @@ function autoBlacklistNeeded (parameters: { if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED || !user) return false if (isRemote || isNew === false) return false - if (user.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK)) return false + if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)) return false return true } diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 4ea175583..fbd3080c6 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -739,11 +739,11 @@ export class UserModel extends Model { const videoUserId = video.VideoChannel.Account.userId if (video.isBlacklisted()) { - return videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) + return videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) } if (video.privacy === VideoPrivacy.PRIVATE) { - return video.VideoChannel && videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) + return video.VideoChannel && videoUserId === this.id || this.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) } if (video.privacy === VideoPrivacy.INTERNAL) return true diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.ts index 70a6ecb03..8cbfe362e 100644 --- a/server/models/video/video-blacklist.ts +++ b/server/models/video/video-blacklist.ts @@ -3,7 +3,7 @@ import { getBlacklistSort, SortType, throwIfNotValid, searchAttribute } from '.. import { VideoModel } from './video' import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist' -import { VideoBlocklist, VideoBlockType } from '../../../shared/models/videos' +import { VideoBlacklist, VideoBlacklistType } from '../../../shared/models/videos' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { FindOptions } from 'sequelize' import { ThumbnailModel } from './thumbnail' @@ -34,7 +34,7 @@ export class VideoBlacklistModel extends Model { @Default(null) @Is('VideoBlacklistType', value => throwIfNotValid(value, isVideoBlacklistTypeValid, 'type')) @Column - type: VideoBlockType + type: VideoBlacklistType @CreatedAt createdAt: Date @@ -59,7 +59,7 @@ export class VideoBlacklistModel extends Model { count: number sort: SortType search?: string - type?: VideoBlockType + type?: VideoBlacklistType }) { const { start, count, sort, search, type } = parameters @@ -119,7 +119,7 @@ export class VideoBlacklistModel extends Model { return VideoBlacklistModel.findOne(query) } - toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlocklist { + toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlacklist { return { id: this.id, createdAt: this.createdAt, diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 94d47408a..472fbda43 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -188,7 +188,7 @@ describe('Test users API validators', function () { videoQuota: -1, videoQuotaDaily: -1, role: UserRole.USER, - adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST } it('Should fail with a too small username', async function () { diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index b96c26989..145f43980 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts @@ -24,7 +24,7 @@ import { checkBadSortPagination, checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' -import { VideoBlockType, VideoDetails } from '../../../../shared/models/videos' +import { VideoBlacklistType, VideoDetails } from '../../../../shared/models/videos' import { expect } from 'chai' describe('Test video blacklist API validators', function () { @@ -243,7 +243,7 @@ describe('Test video blacklist API validators', function () { }) it('Should succeed with the correct parameters', async function () { - await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlockType.MANUAL }) + await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL }) }) }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index af5a5fd25..cad954fcb 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -265,7 +265,7 @@ describe('Test users', function () { username: user.username, password: user.password, videoQuota: 2 * 1024 * 1024, - adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST }) }) @@ -292,7 +292,7 @@ describe('Test users', function () { } expect(userMe.adminFlags).to.be.undefined - expect(userGet.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK) + expect(userGet.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST) expect(userMe.specialPlaylists).to.have.lengthOf(1) expect(userMe.specialPlaylists[0].type).to.equal(VideoPlaylistType.WATCH_LATER) diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index 6e15893f3..a8500627b 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts @@ -25,7 +25,7 @@ import { } from '../../../../shared/extra-utils/index' import { doubleFollow } from '../../../../shared/extra-utils/server/follows' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { VideoBlocklist, VideoBlockType } from '../../../../shared/models/videos' +import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' import { User, UserRole } from '../../../../shared/models/users' import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' @@ -127,7 +127,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlockType.MANUAL + type: VideoBlacklistType.MANUAL }) expect(res.body.total).to.equal(2) @@ -141,7 +141,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(0) @@ -219,7 +219,7 @@ describe('Test video blacklist', function () { }) describe('When removing a blacklisted video', function () { - let videoToRemove: VideoBlocklist + let videoToRemove: VideoBlacklist let blacklist = [] it('Should not have any video in videos list on server 1', async function () { @@ -328,7 +328,7 @@ describe('Test video blacklist', function () { it('Should have the correct video blacklist unfederate attribute', async function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt' }) - const blacklistedVideos: VideoBlocklist[] = res.body.data + const blacklistedVideos: VideoBlacklist[] = res.body.data const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID) @@ -396,7 +396,7 @@ describe('Test video blacklist', function () { url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, - adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK, + adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST, password: user.password, role: UserRole.USER }) @@ -413,7 +413,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(1) @@ -434,7 +434,7 @@ describe('Test video blacklist', function () { url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt', - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(2) @@ -453,7 +453,7 @@ describe('Test video blacklist', function () { url: servers[0].url, token: servers[0].accessToken, sort: 'createdAt', - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(3) @@ -466,7 +466,7 @@ describe('Test video blacklist', function () { const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, - type: VideoBlockType.AUTO_BEFORE_PUBLISHED + type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) expect(res.body.total).to.equal(3) -- cgit v1.2.3