preserve original variable names server-side
authorRigel Kent <sendmemail@rigelk.eu>
Tue, 9 Jun 2020 14:07:10 +0000 (16:07 +0200)
committerRigel Kent <sendmemail@rigelk.eu>
Wed, 10 Jun 2020 19:12:09 +0000 (21:12 +0200)
34 files changed:
client/src/app/+admin/admin.component.ts
client/src/app/+admin/moderation/moderation.component.ts
client/src/app/+admin/moderation/moderation.routes.ts
client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts
client/src/app/+admin/users/user-edit/user-create.component.ts
client/src/app/+admin/users/user-edit/user-edit.component.html
client/src/app/+admin/users/user-edit/user-edit.ts
client/src/app/+admin/users/user-edit/user-update.component.ts
client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts
client/src/app/menu/menu.component.ts
client/src/app/shared/users/user-notification.model.ts
client/src/app/shared/users/user-notifications.component.html
client/src/app/shared/video-block/video-block.service.ts
client/src/app/shared/video/video.model.ts
client/src/app/videos/+video-watch/video-watch.component.ts
server/controllers/api/videos/blacklist.ts
server/helpers/custom-validators/video-blacklist.ts
server/initializers/migrations/0350-video-blacklist-type.ts
server/lib/notifier.ts
server/lib/video-blacklist.ts
server/models/account/user.ts
server/models/video/video-blacklist.ts
server/tests/api/check-params/users.ts
server/tests/api/check-params/video-blacklist.ts
server/tests/api/users/users.ts
server/tests/api/videos/video-blacklist.ts
shared/extra-utils/users/user-notifications.ts
shared/extra-utils/videos/video-blacklist.ts
shared/models/users/user-flag.model.ts
shared/models/users/user-notification.model.ts
shared/models/users/user-right.enum.ts
shared/models/users/user-role.ts
shared/models/videos/blacklist/video-blacklist.model.ts

index 4cf3da0e86debdc9dadba6d2b222ae3ae88aa845..a97a33cf58131a55a954eb9bbc819b11309ddd95 100644 (file)
@@ -37,7 +37,7 @@ export class AdminComponent implements OnInit {
   }
 
   hasVideoBlocklistRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLOCKS)
+    return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
   }
 
   hasConfigRight () {
index d48305eedf5cf161208103eb3f06e679657396b6..1b1df6f09a17fe0693be09f0d612c4eaaab35e9e 100644 (file)
@@ -25,7 +25,7 @@ export class ModerationComponent implements OnInit {
   }
 
   hasVideoBlocklistRight () {
-    return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLOCKS)
+    return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST)
   }
 
   hasAccountsBlocklistRight () {
index aeb555c4a89d118a5831a504363a1d1840decedc..c08333f17d2e27c6636f6346b7ad84fcc2b531c7 100644 (file)
@@ -57,7 +57,7 @@ export const ModerationRoutes: Routes = [
         component: VideoBlockListComponent,
         canActivate: [ UserRightGuard ],
         data: {
-          userRight: UserRight.MANAGE_VIDEO_BLOCKS,
+          userRight: UserRight.MANAGE_VIDEO_BLACKLIST,
           meta: {
             title: 'Videos blocked'
           }
index ca37bccf30e975585b346e05ba9338cd68ec9cb8..a36acc2abdaf3c41432affde437879ddf9ee64c8 100644 (file)
@@ -107,7 +107,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
             this.videoBlocklistService.blockVideo(videoAbuse.video.id, undefined, true)
               .subscribe(
                 () => {
-                  this.notifier.success(this.i18n('Video blocklisted.'))
+                  this.notifier.success(this.i18n('Video blocked.'))
 
                   this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED)
                 },
@@ -123,7 +123,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
             this.videoBlocklistService.unblockVideo(videoAbuse.video.id)
               .subscribe(
                 () => {
-                  this.notifier.success(this.i18n('Video unblocklisted.'))
+                  this.notifier.success(this.i18n('Video unblocked.'))
 
                   this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED)
                 },
index e72ab53481038374a0d16e3ba376bfda1237aa6a..7b3691332b1712430214eb1f65420d1ce4d0f24e 100644 (file)
@@ -3,7 +3,7 @@ import { SortMeta } from 'primeng/api'
 import { Notifier, ServerService } from '@app/core'
 import { ConfirmService } from '../../../core'
 import { RestPagination, RestTable, VideoBlockService } from '../../../shared'
-import { VideoBlocklist, VideoBlockType } from '../../../../../../shared'
+import { VideoBlacklist, VideoBlacklistType } from '../../../../../../shared'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { DropdownAction } from '../../../shared/buttons/action-dropdown.component'
 import { Video } from '../../../shared/video/video.model'
@@ -18,13 +18,13 @@ import { VideoService } from '@app/shared/video/video.service'
   styleUrls: [ '../moderation.component.scss', './video-block-list.component.scss' ]
 })
 export class VideoBlockListComponent extends RestTable implements OnInit {
-  blocklist: (VideoBlocklist & { reasonHtml?: string })[] = []
+  blocklist: (VideoBlacklist & { reasonHtml?: string })[] = []
   totalRecords = 0
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
-  listBlockTypeFilter: VideoBlockType = undefined
+  blocklistTypeFilter: VideoBlacklistType = undefined
 
-  videoBlocklistActions: DropdownAction<VideoBlocklist>[][] = []
+  videoBlocklistActions: DropdownAction<VideoBlacklist>[][] = []
 
   constructor (
     private notifier: Notifier,
@@ -99,7 +99,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
         .subscribe(config => {
           // don't filter if auto-blacklist is not enabled as this will be the only list
           if (config.autoBlacklist.videos.ofUsers.enabled) {
-            this.listBlockTypeFilter = VideoBlockType.MANUAL
+            this.blocklistTypeFilter = VideoBlacklistType.MANUAL
           }
         })
 
@@ -141,7 +141,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
     return 'VideoBlockListComponent'
   }
 
-  getVideoUrl (videoBlock: VideoBlocklist) {
+  getVideoUrl (videoBlock: VideoBlacklist) {
     return Video.buildClientUrl(videoBlock.video.uuid)
   }
 
@@ -155,7 +155,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit {
     return this.markdownRenderer.textMarkdownToHTML(text)
   }
 
-  async unblockVideo (entry: VideoBlocklist) {
+  async unblockVideo (entry: VideoBlacklist) {
     const confirmMessage = this.i18n(
       'Do you really want to unblock this video? It will be available again in the videos list.'
     )
index a394418cb1867115783611e31b41353a621ea89b..b459eb8fa6beec1c89ef4fd2f617219466663793 100644 (file)
@@ -52,7 +52,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
       role: this.userValidatorsService.USER_ROLE,
       videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
       videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
-      byPassAutoBlacklist: null
+      byPassAutoBlock: null
     }, defaultValues)
   }
 
index d30a606d68659fad2d803db966eed2747a338807..0454df7b70559e1d85a70278f31cb9e164e98638 100644 (file)
   
       <div class="form-group">
         <my-peertube-checkbox
-          inputName="byPassAutoBlacklist" formControlName="byPassAutoBlacklist"
+          inputName="byPassAutoBlock" formControlName="byPassAutoBlock"
           i18n-labelText labelText="Doesn't need review before a video goes public"
         ></my-peertube-checkbox>
       </div>
index 98249bcc17a74afc581e08f91d4bd3872d35cd17..5f5cc590cc241d0c5dcc083b85e4583a0fb13858 100644 (file)
@@ -88,7 +88,7 @@ export abstract class UserEdit extends FormReactive implements OnInit {
   }
 
   protected buildAdminFlags (formValue: any) {
-    return formValue.byPassAutoBlacklist ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK : UserAdminFlag.NONE
+    return formValue.byPassAutoBlock ? UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE
   }
 
   protected buildQuotaOptions () {
index f2bd8c8ec1e1e6cda20f45a2c28d4c1761dc5344..035c0d4bb35a417b8e41ffa9c447be256f21cbbc 100644 (file)
@@ -56,7 +56,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
       role: this.userValidatorsService.USER_ROLE,
       videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
       videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
-      byPassAutoBlacklist: null
+      byPassAutoBlock: null
     }, defaultValues)
 
     this.paramsSub = this.route.params.subscribe(routeParams => {
@@ -125,7 +125,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
       role: userJson.role.toString(),
       videoQuota: userJson.videoQuota,
       videoQuotaDaily: userJson.videoQuotaDaily,
-      byPassAutoBlacklist: userJson.adminFlags & UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK
+      byPassAutoBlock: userJson.adminFlags & UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST
     })
   }
 }
index 72e26ac2805eed9686d6df918348e7e9aa6c96fb..af17a0352b075f2f264d0abba61399a943dfc3fe 100644 (file)
@@ -49,7 +49,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
 
     this.rightNotifications = {
       videoAbuseAsModerator: UserRight.MANAGE_VIDEO_ABUSES,
-      videoAutoBlacklistAsModerator: UserRight.MANAGE_VIDEO_BLOCKS,
+      videoAutoBlacklistAsModerator: UserRight.MANAGE_VIDEO_BLACKLIST,
       newUserRegistration: UserRight.MANAGE_USERS,
       newInstanceFollower: UserRight.MANAGE_SERVER_FOLLOW,
       autoInstanceFollowing: UserRight.MANAGE_CONFIGURATION
index 79bf29e9c72501edbe666a39bc702a972fad7cff..ba33425416077f6435ec3f82ba12197893dc0582 100644 (file)
@@ -33,7 +33,7 @@ export class MenuComponent implements OnInit {
     [UserRight.MANAGE_USERS]: '/admin/users',
     [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends',
     [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/moderation/video-abuses',
-    [UserRight.MANAGE_VIDEO_BLOCKS]: '/admin/moderation/video-blocks',
+    [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/moderation/video-blocks',
     [UserRight.MANAGE_JOBS]: '/admin/jobs',
     [UserRight.MANAGE_CONFIGURATION]: '/admin/config'
   }
@@ -131,7 +131,7 @@ export class MenuComponent implements OnInit {
       UserRight.MANAGE_USERS,
       UserRight.MANAGE_SERVER_FOLLOW,
       UserRight.MANAGE_VIDEO_ABUSES,
-      UserRight.MANAGE_VIDEO_BLOCKS,
+      UserRight.MANAGE_VIDEO_BLACKLIST,
       UserRight.MANAGE_JOBS,
       UserRight.MANAGE_CONFIGURATION
     ]
index bc1861c643697d1530bd8a05fbe7e71c1ba2e89d..7b8368d872da81ad5c594f68a124471444b1e9b1 100644 (file)
@@ -96,7 +96,7 @@ export class UserNotification implements UserNotificationServer {
           this.videoUrl = this.buildVideoUrl(this.video)
           break
 
-        case UserNotificationType.UNBLOCK_ON_MY_VIDEO:
+        case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO:
           this.videoUrl = this.buildVideoUrl(this.video)
           break
 
@@ -112,7 +112,7 @@ export class UserNotification implements UserNotificationServer {
           this.videoUrl = this.buildVideoUrl(this.videoAbuse.video)
           break
 
-        case UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS:
+        case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS:
           this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list'
           // Backward compatibility where we did not assign videoBlacklist to this type of notification before
           if (!this.videoBlacklist) this.videoBlacklist = { id: null, video: this.video }
@@ -120,7 +120,7 @@ export class UserNotification implements UserNotificationServer {
           this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video)
           break
 
-        case UserNotificationType.BLOCK_ON_MY_VIDEO:
+        case UserNotificationType.BLACKLIST_ON_MY_VIDEO:
           this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video)
           break
 
index 5a102995a2e82e34f4dbca9cccdc776fc30c5836..c6037f0a9654965270a4a47807ae8f80c7a85657 100644 (file)
@@ -26,7 +26,7 @@
         </ng-template>
       </ng-container>
 
-      <ng-container *ngSwitchCase="UserNotificationType.UNBLOCK_ON_MY_VIDEO">
+      <ng-container *ngSwitchCase="UserNotificationType.UNBLACKLIST_ON_MY_VIDEO">
         <my-global-icon iconName="undo"></my-global-icon>
 
         <div class="message" i18n>
@@ -34,7 +34,7 @@
         </div>
       </ng-container>
 
-      <ng-container *ngSwitchCase="UserNotificationType.BLOCK_ON_MY_VIDEO">
+      <ng-container *ngSwitchCase="UserNotificationType.BLACKLIST_ON_MY_VIDEO">
         <my-global-icon iconName="no"></my-global-icon>
 
         <div class="message" i18n>
         </div>
       </ng-container>
 
-      <ng-container *ngSwitchCase="UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS">
+      <ng-container *ngSwitchCase="UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS">
         <my-global-icon iconName="no"></my-global-icon>
 
         <div class="message" i18n>
-          The recently added video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.videoBlacklist.video.name }}</a> has been <a (click)="markAsRead(notification)" [routerLink]="notification.videoAutoBlacklistUrl">auto-blocked</a>
+          The recently added video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.videoBlacklist.video.name }}</a> has been <a (click)="markAsRead(notification)" [routerLink]="notification.videoAutoBlacklistUrl">automatically blocked</a>
         </div>
       </ng-container>
 
index 67ca1d85bcfadf0d7a839710b29deb44366d4893..31ccc84eadce9fecfaf39f90344ab756796677c0 100644 (file)
@@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
 import { SortMeta } from 'primeng/api'
 import { from as observableFrom, Observable } from 'rxjs'
-import { VideoBlocklist, VideoBlockType, ResultList } from '../../../../../shared'
+import { VideoBlacklist, VideoBlacklistType, ResultList } from '../../../../../shared'
 import { environment } from '../../../environments/environment'
 import { RestExtractor, RestPagination, RestService } from '../rest'
 
@@ -21,8 +21,8 @@ export class VideoBlockService {
     pagination: RestPagination
     sort: SortMeta
     search?: string
-    type?: VideoBlockType
-  }): Observable<ResultList<VideoBlocklist>> {
+    type?: VideoBlacklistType
+  }): Observable<ResultList<VideoBlacklist>> {
     const { pagination, sort, search, type } = options
 
     let params = new HttpParams()
@@ -33,8 +33,8 @@ export class VideoBlockService {
         type: {
           prefix: 'type:',
           handler: v => {
-            if (v === 'manual') return VideoBlockType.MANUAL
-            if (v === 'auto') return VideoBlockType.AUTO_BEFORE_PUBLISHED
+            if (v === 'manual') return VideoBlacklistType.MANUAL
+            if (v === 'auto') return VideoBlacklistType.AUTO_BEFORE_PUBLISHED
 
             return undefined
           }
@@ -44,7 +44,7 @@ export class VideoBlockService {
       params = this.restService.addObjectParams(params, filters)
     }
 
-    return this.authHttp.get<ResultList<VideoBlocklist>>(VideoBlockService.BASE_VIDEOS_URL + 'blacklist', { params })
+    return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlockService.BASE_VIDEOS_URL + 'blacklist', { params })
                .pipe(
                  map(res => this.restExtractor.convertResultListDateToHuman(res)),
                  catchError(res => this.restExtractor.handleError(res))
index 2b3d915ef9d45b531bcf7bf3658606dadab191bd..16e43cbd823cd2fc1e86f2e3e5e017a84bc846d9 100644 (file)
@@ -164,11 +164,11 @@ export class Video implements VideoServerModel {
   }
 
   isBlockableBy (user: AuthUser) {
-    return this.blacklisted !== true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) === true
+    return this.blacklisted !== true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
   }
 
   isUnblockableBy (user: AuthUser) {
-    return this.blacklisted === true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) === true
+    return this.blacklisted === true && user && user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) === true
   }
 
   isUpdatableBy (user: AuthUser) {
index 9f726cf35e37fc4f2e70d735c0fc56f5c56d425d..df0c1058ce10296e961f7f0f71055ccbfb36dff7 100644 (file)
@@ -335,7 +335,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
       this.videoCaptionService.listCaptions(videoId)
     ])
       .pipe(
-        // If 401, the video is private or blocklisted so redirect to 404
+        // If 401, the video is private or blocked so redirect to 404
         catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
       )
       .subscribe(([ video, captionsResult ]) => {
@@ -364,7 +364,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
     this.playlistService.getVideoPlaylist(playlistId)
       .pipe(
-        // If 401, the video is private or blocklisted so redirect to 404
+        // If 401, the video is private or blocked so redirect to 404
         catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
       )
       .subscribe(playlist => {
index 2c6948923d8d652b3f0002b53a7d13b038447a78..3b25ceea28bbbfe04e3104999024180a0209eb76 100644 (file)
@@ -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)
 )
index de6726b8f993226221bcab283d129fb180711aff..17cb3b00b6b313f62474cb012ddeda3cd290cbea 100644 (file)
@@ -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
 }
 
 // ---------------------------------------------------------------------------
index 22c82e431ac16b4b6d9bce470645ce9ae31928e3..f79ae5ec7e6512db4c1960525b330b1a46001033 100644 (file)
@@ -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)
   }
 
index 3e90bb57e8a461a38ae9aa06c4c939f44810c023..89f91e0311c6db307f7ff4a1c294c207dfae431f 100644 (file)
@@ -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<UserNotificationModelForApi>({
-        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<UserNotificationModelForApi>({
-        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<UserNotificationModelForApi>({
-        type: UserNotificationType.UNBLOCK_ON_MY_VIDEO,
+        type: UserNotificationType.UNBLACKLIST_ON_MY_VIDEO,
         userId: user.id,
         videoId: video.id
       })
index f1657e8f1dd509133ad1ea210e47824745b0b075..1ee92d22c61ea6faa39f3c7598f861f513feb234 100644 (file)
@@ -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<MVideoBlacklistVideo>({
     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
 }
index 4ea175583b66806c98060665483e3ff5c88fe72f..fbd3080c6a82c5803c716f970bb4ea3d083537b4 100644 (file)
@@ -739,11 +739,11 @@ export class UserModel extends Model<UserModel> {
     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
index 70a6ecb039e1c769dcc800e37201e51410282e52..8cbfe362e87e87646df9ce4ef312b2c06fa61c63 100644 (file)
@@ -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<VideoBlacklistModel> {
   @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<VideoBlacklistModel> {
     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<VideoBlacklistModel> {
     return VideoBlacklistModel.findOne(query)
   }
 
-  toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlocklist {
+  toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlacklist {
     return {
       id: this.id,
       createdAt: this.createdAt,
index 94d47408aa634ff42a9942b8526e76ff4faa45f3..472fbda4314e6628211f8e5805cce71dfc52a700 100644 (file)
@@ -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 () {
index b96c269892900a399aed52e06b4035a9208b3882..145f43980333144d9efcdacebff12545264c0581 100644 (file)
@@ -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 })
     })
   })
 
index af5a5fd258d04c383e830b50d8e9891159f9b65f..cad954fcbdb7086e4ad372190f49624865756523 100644 (file)
@@ -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)
index 6e15893f3ac59eba04c64db2f48f7727c90591f9..a8500627bcc5e2a14d2cfae88dc038763fd337aa 100644 (file)
@@ -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)
index 6f85bd450c8787b5001c00f4219a69c5b650555a..bd00894c466b95a0d552f1c59b65d3205c5de56b 100644 (file)
@@ -455,7 +455,7 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU
 }
 
 async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
-  const notificationType = UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS
+  const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
 
   function notificationChecker (notification: UserNotification, type: CheckerType) {
     if (type === 'presence') {
@@ -486,8 +486,8 @@ async function checkNewBlacklistOnMyVideo (
   blacklistType: 'blacklist' | 'unblacklist'
 ) {
   const notificationType = blacklistType === 'blacklist'
-    ? UserNotificationType.BLOCK_ON_MY_VIDEO
-    : UserNotificationType.UNBLOCK_ON_MY_VIDEO
+    ? UserNotificationType.BLACKLIST_ON_MY_VIDEO
+    : UserNotificationType.UNBLACKLIST_ON_MY_VIDEO
 
   function notificationChecker (notification: UserNotification) {
     expect(notification).to.not.be.undefined
index c06b2aa5db74912ce10c3e0689df77323e775f8b..ba139ef95269ad7c682c62772098ccd9954e9f9d 100644 (file)
@@ -1,5 +1,5 @@
 import * as request from 'supertest'
-import { VideoBlockType } from '../../models/videos'
+import { VideoBlacklistType } from '../../models/videos'
 import { makeGetRequest } from '..'
 
 function addVideoToBlacklist (
@@ -45,7 +45,7 @@ function getBlacklistedVideosList (parameters: {
   url: string
   token: string
   sort?: string
-  type?: VideoBlockType
+  type?: VideoBlacklistType
   specialStatus?: number
 }) {
   const { url, token, sort, type, specialStatus = 200 } = parameters
index e8b5a5c50a4dc85e667833c6a191c99c7778f581..b94262d5e49879908131f5e09ea9a643988007e1 100644 (file)
@@ -1,4 +1,4 @@
 export enum UserAdminFlag {
   NONE = 0,
-  BYPASS_VIDEO_AUTO_BLOCK = 1 << 0
+  BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0
 }
index 2329503a8a0a0c8e8a989ee4988e27194594c917..e9be1ca7fd76c6a7f844f6304dcb6f45c63ad7f8 100644 (file)
@@ -5,8 +5,8 @@ export enum UserNotificationType {
   NEW_COMMENT_ON_MY_VIDEO = 2,
   NEW_VIDEO_ABUSE_FOR_MODERATORS = 3,
 
-  BLOCK_ON_MY_VIDEO = 4,
-  UNBLOCK_ON_MY_VIDEO = 5,
+  BLACKLIST_ON_MY_VIDEO = 4,
+  UNBLACKLIST_ON_MY_VIDEO = 5,
 
   MY_VIDEO_PUBLISHED = 6,
 
@@ -17,7 +17,7 @@ export enum UserNotificationType {
   NEW_FOLLOW = 10,
   COMMENT_MENTION = 11,
 
-  VIDEO_AUTO_BLOCK_FOR_MODERATORS = 12,
+  VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12,
 
   NEW_INSTANCE_FOLLOWER = 13,
 
index 3fb760709fec4c673d9269243dd7924bc7da6c27..2f88a65ded827a7c24be60119586bca7f2c9903b 100644 (file)
@@ -20,7 +20,7 @@ export enum UserRight {
   MANAGE_ACCOUNTS_BLOCKLIST,
   MANAGE_SERVERS_BLOCKLIST,
 
-  MANAGE_VIDEO_BLOCKS,
+  MANAGE_VIDEO_BLACKLIST,
 
   REMOVE_ANY_VIDEO,
   REMOVE_ANY_VIDEO_CHANNEL,
index 30ec5edce2440812e92dd2e151aae32eac2b432d..2b08b585029901d17c0e417cba6d381f38c1c845 100644 (file)
@@ -19,7 +19,7 @@ const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
   ],
 
   [UserRole.MODERATOR]: [
-    UserRight.MANAGE_VIDEO_BLOCKS,
+    UserRight.MANAGE_VIDEO_BLACKLIST,
     UserRight.MANAGE_VIDEO_ABUSES,
     UserRight.REMOVE_ANY_VIDEO,
     UserRight.REMOVE_ANY_VIDEO_CHANNEL,
index e6090b1e93adc631080d6a9ac99f62802d1d794c..a6e0ef175a59d0dca83ebe3112a311ea48e5af64 100644 (file)
@@ -1,15 +1,15 @@
 import { Video } from '../video.model'
 
-export enum VideoBlockType {
+export enum VideoBlacklistType {
   MANUAL = 1,
   AUTO_BEFORE_PUBLISHED = 2
 }
 
-export interface VideoBlocklist {
+export interface VideoBlacklist {
   id: number
   unfederated: boolean
   reason?: string
-  type: VideoBlockType
+  type: VideoBlacklistType
 
   video: Video