ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to set an internal not to blacklists
Chocobozzz5c07542ead9f
diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.htmlindex e267d7cd41..4dc41aabff 100644--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.html@@ -47,6 +47,10 @@}</td>+ <td class="max-width-300px ellipsis" container="body" placement="left auto" [ngbTooltip]="videoBlock.internalNote">+ {{ videoBlock.internalNote }}+ </td>+<td>{{ videoBlock.createdAt | ptDate: 'short' }}</td>@@ -64,8 +68,17 @@<div class="d-flex moderation-expanded"><div class="left">@if (videoBlock.reasonHtml) {- <span class="moderation-expanded-label" i18n>Block reason:</span>- <span class="moderation-expanded-text" [innerHTML]="videoBlock.reasonHtml"></span>+ <div>+ <span class="moderation-expanded-label" i18n>Block reason:</span>+ <span class="moderation-expanded-text" [innerHTML]="videoBlock.reasonHtml"></span>+ </div>+ }++ @if (videoBlock.internalNote) {+ <div>+ <span class="moderation-expanded-label" i18n>Internal note:</span>+ <span class="moderation-expanded-text" [innerHTML]="videoBlock.internalNote | nl2br"></span>+ </div>}</div>@@ -85,3 +98,5 @@</ng-template></my-table>+<my-video-block-internal-note-modal #internalNoteModal (internalNoteUpdated)="table.loadData()"></my-video-block-internal-note-modal>+diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.tsindex 752aee1245..b29d5369ba 100644--- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts+++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts@@ -6,8 +6,10 @@ import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoService } from '@app/shared/shared-main/video/video.service'import { AccountBlockBadgeInput } from '@app/shared/shared-moderation/account-block-badges.component'import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'+import { VideoBlockInternalNoteModalComponent } from '@app/shared/shared-moderation/video-block-internal-note-modal.component'import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'import { PrivacyBadgeComponent } from '@app/shared/shared-video/privacy-badge.component'+import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'import { buildVideoEmbedLink, decorateVideoLink } from '@peertube/peertube-core-utils'import { ResultList, VideoBlacklist as VideoBlacklistServer, VideoBlacklistType, VideoBlacklistType_Type } from '@peertube/peertube-models'import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'@@ -15,6 +17,7 @@ import { switchMap } from 'rxjs/operators'import { environment } from '../../../../environments/environment'import { AdvancedFilterDef } from '../../../shared/shared-forms/advanced-input-filter.component'import { ActionDropdownComponent, DropdownAction } from '../../../shared/shared-main/buttons/action-dropdown.component'+import { Nl2BrPipe } from '../../../shared/shared-main/common/nl2br.pipe'import { NumberFormatterPipe } from '../../../shared/shared-main/common/number-formatter.pipe'import { EmbedComponent } from '../../../shared/shared-main/video/embed.component'import { DataLoaderOptionsBase, TableColumnInfo, TableComponent } from '../../../shared/shared-tables/table.component'@@ -36,7 +39,10 @@ type VideoBlacklist = VideoBlacklistServer & { reasonHtml?: string }VideoNSFWBadgeComponent,TableComponent,NumberFormatterPipe,- PrivacyBadgeComponent+ PrivacyBadgeComponent,+ NgbTooltipModule,+ VideoBlockInternalNoteModalComponent,+ Nl2BrPipe]})export class VideoBlockListComponent implements OnInit {@@ -49,6 +55,7 @@ export class VideoBlockListComponent implements OnInit {private videoService = inject(VideoService)readonly table = viewChild<TableComponent<VideoBlacklist, DataLoaderParameter>>('table')+ readonly internalNoteModal = viewChild<VideoBlockInternalNoteModalComponent>('internalNoteModal')blocklistTypeFilter: VideoBlacklistType_Type@@ -74,6 +81,7 @@ export class VideoBlockListComponent implements OnInit {{ id: 'privacy', label: $localize`Privacy`, sortable: false },{ id: 'sensitive', label: $localize`Sensitive`, sortable: false },{ id: 'unfederated', label: $localize`Unfederated`, sortable: false },+ { id: 'internalNote', label: $localize`Internal note`, sortable: false },{ id: 'createdAt', label: $localize`Date`, sortable: true }]@@ -90,7 +98,6 @@ export class VideoBlockListComponent implements OnInit {{label: () => $localize`Internal actions`,isHeader: true,- isDisplayed: videoBlock => videoBlock.type !== VideoBlacklistType.MANUAL,enableBulk: true},{@@ -98,6 +105,11 @@ export class VideoBlockListComponent implements OnInit {handler: videoBlocks => this.switchVideosBlockToManual(videoBlocks),isDisplayed: videoBlock => videoBlock.type !== VideoBlacklistType.MANUAL,enableBulk: true+ },+ {+ label: () => $localize`Set internal note`,+ handler: entries => this.internalNoteModal().openModal(entries),+ enableBulk: true}],[@@ -106,6 +118,7 @@ export class VideoBlockListComponent implements OnInit {isHeader: true,enableBulk: true},+{label: () => $localize`Unblock`,handler: entries => this.unblockVideos(entries),diff --git a/client/src/app/shared/form-validators/video-block-validators.ts b/client/src/app/shared/form-validators/video-block-validators.tsindex cd2791b761..3bc1037867 100644--- a/client/src/app/shared/form-validators/video-block-validators.ts+++ b/client/src/app/shared/form-validators/video-block-validators.ts@@ -8,3 +8,11 @@ export const VIDEO_BLOCK_REASON_VALIDATOR: BuildFormValidator = {maxlength: $localize`Block reason cannot be more than 300 characters long.`}}++export const VIDEO_BLOCK_INTERNAL_NOTE_VALIDATOR: BuildFormValidator = {+ VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],+ MESSAGES: {+ minlength: $localize`Internal note must be at least 2 characters long.`,+ maxlength: $localize`Internal note cannot be more than 300 characters long.`+ }+}diff --git a/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.html b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.htmlnew file mode 100644index 0000000000..01ccc417ac--- /dev/null+++ b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.html@@ -0,0 +1,33 @@+<ng-template #modal>+ <div class="modal-header">+ <h4 i18n class="modal-title">{{ getModalTitle() }}</h4>++ <button class="border-0 p-0" title="Close this modal" i18n-title (click)="hide()">+ <my-global-icon iconName="cross"></my-global-icon>+ </button>+ </div>++ <div class="modal-body">+ <form novalidate [formGroup]="form" (ngSubmit)="save()">+ <div class="form-group">+ <textarea+ i18n-placeholder placeholder="Internal note..." formControlName="internalNote"+ class="form-control" [ngClass]="{ 'input-error': formErrors['internalNote'] }"+ ></textarea>++ @if (formErrors.internalNote) {+ <div class="form-error" role="alert">{{ formErrors.internalNote }}</div>+ }+ </div>++ <div class="form-group inputs">+ <input+ type="button" role="button" i18n-value value="Cancel" class="peertube-button secondary-button"+ (click)="hide()" (key.enter)="hide()"+ >++ <input type="submit" i18n-value value="Save" class="peertube-button primary-button" [disabled]="!form.valid" />+ </div>+ </form>+ </div>+</ng-template>diff --git a/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.scss b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.scssnew file mode 100644index 0000000000..ad19daac7f--- /dev/null+++ b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.scss@@ -0,0 +1,7 @@+@use "_variables" as *;+@use "_mixins" as *;+@use "_form-mixins" as *;++textarea {+ @include peertube-textarea(100%, 60px);+}diff --git a/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.ts b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.tsnew file mode 100644index 0000000000..7b735deffd--- /dev/null+++ b/client/src/app/shared/shared-moderation/video-block-internal-note-modal.component.ts@@ -0,0 +1,90 @@+import { NgClass } from '@angular/common'+import { Component, OnInit, inject, output, viewChild } from '@angular/core'+import { FormsModule, ReactiveFormsModule } from '@angular/forms'+import { Notifier } from '@app/core'+import { formatICU } from '@app/helpers'+import { FormReactive } from '@app/shared/shared-forms/form-reactive'+import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'+import { VideoBlacklist } from '@peertube/peertube-models'+import { VIDEO_BLOCK_INTERNAL_NOTE_VALIDATOR } from '../form-validators/video-block-validators'+import { GlobalIconComponent } from '../shared-icons/global-icon.component'+import { VideoBlockService } from './video-block.service'++@Component({+ selector: 'my-video-block-internal-note-modal',+ templateUrl: './video-block-internal-note-modal.component.html',+ styleUrls: [ './video-block-internal-note-modal.component.scss' ],+ imports: [ GlobalIconComponent, FormsModule, ReactiveFormsModule, NgClass ]+})+export class VideoBlockInternalNoteModalComponent extends FormReactive implements OnInit {+ protected formReactiveService = inject(FormReactiveService)+ private modalService = inject(NgbModal)+ private notifier = inject(Notifier)+ private videoBlocklistService = inject(VideoBlockService)++ readonly modal = viewChild<NgbModal>('modal')+ readonly internalNoteUpdated = output()++ private entries: VideoBlacklist[]+ private openedModal: NgbModalRef++ ngOnInit () {+ this.buildForm({+ internalNote: VIDEO_BLOCK_INTERNAL_NOTE_VALIDATOR+ })+ }++ openModal (entries: VideoBlacklist[]) {+ this.entries = entries++ const currentNote = entries.length === 1+ ? entries[0].internalNote+ : ''++ this.form.controls['internalNote'].setValue(currentNote)++ this.openedModal = this.modalService.open(this.modal(), { centered: true })+ }++ hide () {+ this.entries = undefined+ this.openedModal.close()+ }++ getModalTitle () {+ if (this.entries?.length === 1) {+ return $localize`Set internal note`+ }++ return formatICU(+ $localize`Set internal note for {count} videos`,+ { count: this.entries?.length ?? 0 }+ )+ }++ save () {+ const note = this.form.value['internalNote'] || null++ this.videoBlocklistService.updateBlocks(+ this.entries.map(entry => ({ videoId: entry.video.id, internalNote: note }))+ ).subscribe({+ next: () => {+ for (const entry of this.entries) {+ entry.internalNote = note+ }++ this.notifier.success(+ formatICU(+ $localize`{count, plural, =1 {Internal note updated} other {{count} internal notes updated}}`,+ { count: this.entries.length }+ )+ )+ this.internalNoteUpdated.emit()+ this.hide()+ },++ error: err => this.notifier.handleError(err)+ })+ }+}diff --git a/client/src/app/shared/shared-moderation/video-block.service.ts b/client/src/app/shared/shared-moderation/video-block.service.tsindex 5128eeddea..9c17e5e16d 100644--- a/client/src/app/shared/shared-moderation/video-block.service.ts+++ b/client/src/app/shared/shared-moderation/video-block.service.ts@@ -2,7 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'import { Injectable, inject } from '@angular/core'import { RestExtractor, RestPagination, RestService } from '@app/core'import { arrayify } from '@peertube/peertube-core-utils'-import { ResultList, VideoBlacklist, VideoBlacklistType_Type } from '@peertube/peertube-models'+import { ResultList, VideoBlacklist, VideoBlacklistType_Type, VideoBlacklistUpdate } from '@peertube/peertube-models'import { SortMeta } from 'primeng/api'import { Observable, from as observableFrom } from 'rxjs'import { catchError, concatMap, toArray } from 'rxjs/operators'@@ -61,4 +61,24 @@ export class VideoBlockService {catchError(res => this.restExtractor.handleError(res)))}++ updateBlocks (options: {+ videoId: number | string+ reason?: string+ internalNote?: string+ }[]) {+ return observableFrom(options)+ .pipe(+ concatMap(({ videoId, reason, internalNote }) => {+ const body: VideoBlacklistUpdate = {}++ if (reason !== undefined) body.reason = reason+ if (internalNote !== undefined) body.internalNote = internalNote++ return this.authHttp.put(VideoBlockService.BASE_VIDEOS_URL + videoId + '/blacklist', body)+ }),+ toArray(),+ catchError(res => this.restExtractor.handleError(res))+ )+ }}diff --git a/packages/models/src/videos/blacklist/video-blacklist-create.model.ts b/packages/models/src/videos/blacklist/video-blacklist-create.model.tsindex 6e7d36421d..86e8d3a1c2 100644--- a/packages/models/src/videos/blacklist/video-blacklist-create.model.ts+++ b/packages/models/src/videos/blacklist/video-blacklist-create.model.ts@@ -1,4 +1,5 @@export interface VideoBlacklistCreate {reason?: stringunfederate?: boolean+ internalNote?: string}diff --git a/packages/models/src/videos/blacklist/video-blacklist-update.model.ts b/packages/models/src/videos/blacklist/video-blacklist-update.model.tsindex 0a86cf7b00..58c8fcc12e 100644--- a/packages/models/src/videos/blacklist/video-blacklist-update.model.ts+++ b/packages/models/src/videos/blacklist/video-blacklist-update.model.ts@@ -1,3 +1,4 @@export interface VideoBlacklistUpdate {reason?: string+ internalNote?: string}diff --git a/packages/models/src/videos/blacklist/video-blacklist.model.ts b/packages/models/src/videos/blacklist/video-blacklist.model.tsindex 71d33ddd86..1b82ec9c48 100644--- a/packages/models/src/videos/blacklist/video-blacklist.model.ts+++ b/packages/models/src/videos/blacklist/video-blacklist.model.ts@@ -12,6 +12,7 @@ export interface VideoBlacklist {id: numberunfederated: booleanreason?: string+ internalNote?: stringtype: VideoBlacklistType_Typevideo: Videodiff --git a/packages/server-commands/src/videos/blacklist-command.ts b/packages/server-commands/src/videos/blacklist-command.tsindex d41001e268..3c1d195344 100644--- a/packages/server-commands/src/videos/blacklist-command.ts+++ b/packages/server-commands/src/videos/blacklist-command.ts@@ -2,45 +2,52 @@ import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType_Type } fimport { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'export class BlacklistCommand extends AbstractCommand {-- add (options: OverrideCommandOptions & {- videoId: number | string- reason?: string- unfederate?: boolean- }) {- const { videoId, reason, unfederate } = options+ add (+ options: OverrideCommandOptions & {+ videoId: number | string+ reason?: string+ unfederate?: boolean+ internalNote?: string+ }+ ) {+ const { videoId, reason, unfederate, internalNote } = optionsconst path = '/api/v1/videos/' + videoId + '/blacklist'return this.postBodyRequest({...options,path,- fields: { reason, unfederate },+ fields: { reason, unfederate, internalNote },implicitToken: true,defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204})}- update (options: OverrideCommandOptions & {- videoId: number | string- reason?: string- }) {- const { videoId, reason } = options+ update (+ options: OverrideCommandOptions & {+ videoId: number | string+ reason?: string+ internalNote?: string+ }+ ) {+ const { videoId, reason, internalNote } = optionsconst path = '/api/v1/videos/' + videoId + '/blacklist'return this.putBodyRequest({...options,path,- fields: { reason },+ fields: { reason, internalNote },implicitToken: true,defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204})}- remove (options: OverrideCommandOptions & {- videoId: number | string- }) {+ remove (+ options: OverrideCommandOptions & {+ videoId: number | string+ }+ ) {const { videoId } = optionsconst path = '/api/v1/videos/' + videoId + '/blacklist'diff --git a/packages/tests/src/api/check-params/video-blacklist.ts b/packages/tests/src/api/check-params/video-blacklist.tsindex 34c5850d4e..e40d259ce1 100644--- a/packages/tests/src/api/check-params/video-blacklist.ts+++ b/packages/tests/src/api/check-params/video-blacklist.ts@@ -98,6 +98,13 @@ describe('Test video blacklist API validators', function () {await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })})+ it('Should fail with an invalid internal note', async function () {+ const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'+ const fields = { internalNote: 'a'.repeat(305) }++ await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })+ })+it('Should fail to unfederate a remote video', async function () {const path = basePath + remoteVideoUUID + '/blacklist'const fields = { unfederate: true }@@ -171,9 +178,16 @@ describe('Test video blacklist API validators', function () {await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })})+ it('Should fail with an invalid internal note', async function () {+ const path = basePath + servers[0].store.videoCreated.uuid + '/blacklist'+ const fields = { internalNote: 'a'.repeat(305) }++ await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })+ })+it('Should succeed with the correct params', async function () {const path = basePath + servers[0].store.videoCreated.shortUUID + '/blacklist'- const fields = { reason: 'hello' }+ const fields = { reason: 'hello', internalNote: 'internal note test' }await makePutBodyRequest({url: servers[0].url,diff --git a/packages/tests/src/api/moderation/video-blacklist.ts b/packages/tests/src/api/moderation/video-blacklist.tsindex da93211024..3e4bb7d972 100644--- a/packages/tests/src/api/moderation/video-blacklist.ts+++ b/packages/tests/src/api/moderation/video-blacklist.ts@@ -172,6 +172,33 @@ describe('Test video blacklist', function () {expect(video.reason).to.equal('my super reason updated')})++ it('Should set an internal note', async function () {+ await command.update({ videoId, internalNote: 'internal moderation note' })++ const body = await command.list()+ const video = body.data.find(b => b.video.id === videoId)++ expect(video.internalNote).to.equal('internal moderation note')+ })++ it('Should update the internal note', async function () {+ await command.update({ videoId, internalNote: 'updated internal note' })++ const body = await command.list()+ const video = body.data.find(b => b.video.id === videoId)++ expect(video.internalNote).to.equal('updated internal note')+ })++ it('Should clear the internal note', async function () {+ await command.update({ videoId, internalNote: null })++ const body = await command.list()+ const video = body.data.find(b => b.video.id === videoId)++ expect(video.internalNote).to.not.exist+ })})describe('When listing my videos', function () {@@ -251,7 +278,15 @@ describe('Test video blacklist', function () {})it('Should blacklist video 3 and keep it federated', async function () {- await command.add({ videoId: video3UUID, reason: 'super reason', unfederate: false })+ // TODO: check reason and internal note+ await command.add({ videoId: video3UUID, reason: 'super reason', internalNote: 'my internal note', unfederate: false })++ {+ const { data } = await servers[0].blacklist.list({ sort: '-createdAt' })+ const blacklist = data[0]+ expect(blacklist.reason).to.equal('super reason')+ expect(blacklist.internalNote).to.equal('my internal note')+ }await waitJobs(servers)diff --git a/server/core/controllers/api/videos/blacklist.ts b/server/core/controllers/api/videos/blacklist.tsindex e93eeae9c9..5cb6203457 100644--- a/server/core/controllers/api/videos/blacklist.ts+++ b/server/core/controllers/api/videos/blacklist.ts@@ -1,6 +1,6 @@import express from 'express'import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist.js'-import { HttpStatusCode, UserRight, VideoBlacklistCreate } from '@peertube/peertube-models'+import { HttpStatusCode, UserRight, VideoBlacklistCreate, VideoBlacklistUpdate } from '@peertube/peertube-models'import { logger } from '../../../helpers/logger.js'import { getFormattedObjects } from '../../../helpers/utils.js'import { sequelizeTypescript } from '../../../initializers/database.js'@@ -82,8 +82,10 @@ async function addVideoToBlacklistController (req: express.Request, res: expressasync function updateVideoBlacklistController (req: express.Request, res: express.Response) {const videoBlacklist = res.locals.videoBlacklist+ const body: VideoBlacklistUpdate = req.body- if (req.body.reason !== undefined) videoBlacklist.reason = req.body.reason+ if (body.reason !== undefined) videoBlacklist.reason = body.reason+ if (body.internalNote !== undefined) videoBlacklist.internalNote = body.internalNoteawait sequelizeTypescript.transaction(t => {return videoBlacklist.save({ transaction: t })diff --git a/server/core/helpers/custom-validators/video-blacklist.ts b/server/core/helpers/custom-validators/video-blacklist.tsindex e8593a79e1..51a77ad3a1 100644--- a/server/core/helpers/custom-validators/video-blacklist.ts+++ b/server/core/helpers/custom-validators/video-blacklist.ts@@ -9,6 +9,10 @@ export function isVideoBlacklistReasonValid (value: string) {return value === null || validator.default.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)}+export function isVideoBlacklistInternalNoteValid (value: string) {+ return value === null || validator.default.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.INTERNAL_NOTE)+}+export function isVideoBlacklistTypeValid (value: any) {return exists(value) &&(diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.tsindex 1a0b575b53..d2ed30231f 100644--- a/server/core/initializers/constants.ts+++ b/server/core/initializers/constants.ts@@ -62,7 +62,7 @@ import { CONFIG, registerConfigChangedHandler } from './config.js'// ----------------------------------------------------------------------------export const LAST_MIGRATION_VERSION = 1050+export const LAST_MIGRATION_VERSION = 1055// ---------------------------------------------------------------------------@@ -409,7 +409,8 @@ export const CONSTRAINTS_FIELDS = {MODERATOR_MESSAGE: { min: 2, max: 3000 } // Length},VIDEO_BLACKLIST: {- REASON: { min: 2, max: 300 } // Length+ REASON: { min: 2, max: 300 }, // Length+ INTERNAL_NOTE: { min: 2, max: 300 } // Length},VIDEO_CHANNELS: {NAME: { min: 1, max: 120 }, // Lengthdiff --git a/server/core/initializers/migrations/1055-video-blacklist-internal-note.ts b/server/core/initializers/migrations/1055-video-blacklist-internal-note.tsnew file mode 100644index 0000000000..3901d2d7ea--- /dev/null+++ b/server/core/initializers/migrations/1055-video-blacklist-internal-note.ts@@ -0,0 +1,26 @@+import * as Sequelize from 'sequelize'++async function up (utils: {+ transaction: Sequelize.Transaction+ queryInterface: Sequelize.QueryInterface+ sequelize: Sequelize.Sequelize+}): Promise<void> {+ await utils.sequelize.query(+ `ALTER TABLE "videoBlacklist" ` ++ `ADD COLUMN IF NOT EXISTS "internalNote" VARCHAR(300)`,+ { transaction: utils.transaction }+ )+}++async function down (utils: {+ transaction: Sequelize.Transaction+ queryInterface: Sequelize.QueryInterface+ sequelize: Sequelize.Sequelize+}): Promise<void> {+ await utils.sequelize.query(+ `ALTER TABLE "videoBlacklist" DROP COLUMN IF EXISTS "internalNote"`,+ { transaction: utils.transaction }+ )+}++export { down, up }diff --git a/server/core/lib/video-blacklist.ts b/server/core/lib/video-blacklist.tsindex 8a40744c47..2ffbee00e9 100644--- a/server/core/lib/video-blacklist.ts+++ b/server/core/lib/video-blacklist.ts@@ -151,6 +151,7 @@ export async function blacklistVideo (videoInstance: MVideoAccountLight, optionsvideoId: videoInstance.id,unfederated: options.unfederate === true,reason: options.reason,+ internalNote: options.internalNote,type: VideoBlacklistType.MANUAL})blacklist.Video = videoInstancediff --git a/server/core/middlewares/validators/videos/video-blacklist.ts b/server/core/middlewares/validators/videos/video-blacklist.tsindex 666d8061d5..640f92cb5e 100644--- a/server/core/middlewares/validators/videos/video-blacklist.ts+++ b/server/core/middlewares/validators/videos/video-blacklist.ts@@ -2,7 +2,11 @@ import express from 'express'import { body, query } from 'express-validator'import { HttpStatusCode } from '@peertube/peertube-models'import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'-import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist.js'+import {+ isVideoBlacklistReasonValid,+ isVideoBlacklistInternalNoteValid,+ isVideoBlacklistTypeValid+} from '../../../helpers/custom-validators/video-blacklist.js'import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'export const videosBlacklistRemoveValidator = [@@ -27,6 +31,9 @@ export const videosBlacklistAddValidator = [body('reason').optional().custom(isVideoBlacklistReasonValid),+ body('internalNote')+ .optional()+ .custom(isVideoBlacklistInternalNoteValid).withMessage('Should have a valid internal note'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) return@@ -50,6 +57,9 @@ export const videosBlacklistUpdateValidator = [body('reason').optional().custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),+ body('internalNote')+ .optional()+ .custom(isVideoBlacklistInternalNoteValid).withMessage('Should have a valid internal note'),async (req: express.Request, res: express.Response, next: express.NextFunction) => {if (areValidationErrors(req, res)) returndiff --git a/server/core/models/video/video-blacklist.ts b/server/core/models/video/video-blacklist.tsindex 4e7eb38760..dd4ac9dc83 100644--- a/server/core/models/video/video-blacklist.ts+++ b/server/core/models/video/video-blacklist.ts@@ -2,7 +2,7 @@ import { VideoBlacklist, type VideoBlacklistType_Type } from '@peertube/peertubeimport { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/types/models/index.js'import { FindOptions } from 'sequelize'import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Table, UpdatedAt } from 'sequelize-typescript'-import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist.js'+import { isVideoBlacklistReasonValid, isVideoBlacklistInternalNoteValid, isVideoBlacklistTypeValid } from '../../helpers/custom-validators/video-blacklist.js'import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js'import { getBlacklistSort, searchAttribute, SequelizeModel, throwIfNotValid } from '../shared/index.js'import { thumbnailAPIAttributes, ThumbnailModel } from './thumbnail.js'@@ -24,6 +24,11 @@ export class VideoBlacklistModel extends SequelizeModel<VideoBlacklistModel> {@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max))declare reason: string+ @AllowNull(true)+ @Is('VideoBlacklistInternalNote', value => throwIfNotValid(value, isVideoBlacklistInternalNoteValid, 'internalNote', true))+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.INTERNAL_NOTE.max))+ declare internalNote: string+@AllowNull(false)@Columndeclare unfederated: boolean@@ -123,6 +128,7 @@ export class VideoBlacklistModel extends SequelizeModel<VideoBlacklistModel> {createdAt: this.createdAt,updatedAt: this.updatedAt,reason: this.reason,+ internalNote: this.internalNote,unfederated: this.unfederated,type: this.type,diff --git a/server/core/types/models/video/video-blacklist.ts b/server/core/types/models/video/video-blacklist.tsindex dc35191a36..68eb2a437b 100644--- a/server/core/types/models/video/video-blacklist.ts+++ b/server/core/types/models/video/video-blacklist.ts@@ -8,7 +8,7 @@ type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel,export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'>-export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>+export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'internalNote' | 'unfederated'>export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>// ############################################################################diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 1c6a334a67..8c536a9dba 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -4716,9 +4716,35 @@ paths:- Video Blocksparameters:- $ref: '#/components/parameters/idOrUUID'+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/VideoBlacklistCreate'responses:'204':description: successful operation+ put:+ summary: Update a video block+ operationId: updateVideoBlock+ security:+ - OAuth2:+ - admin+ - moderator+ tags:+ - Video Blocks+ parameters:+ - $ref: '#/components/parameters/idOrUUID'+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/VideoBlacklistUpdate'+ responses:+ '204':+ description: successful operation+ '404':+ description: block not founddelete:summary: Unblock a video by its idoperationId: delVideoBlock@@ -10988,37 +11014,53 @@ components:account:$ref: '#/components/schemas/AccountSummary'VideoBlacklist:+ type: objectproperties:id:$ref: '#/components/schemas/id'- videoId:- $ref: '#/components/schemas/Video/properties/id'+ reason:+ type: string+ description: Reason for the block (public)+ internalNote:+ type: string+ description: Internal note for moderators/admins+ unfederated:+ type: boolean+ type:+ type: integer+ description: >+ - `1`: manual block+ - `2`: automatic block by instance policy+ - `3`: automatic block by auto-tag policy+ video:+ $ref: '#/components/schemas/Video'createdAt:type: stringformat: date-timeupdatedAt:type: stringformat: date-time- name:- type: string- minLength: 3- maxLength: 120- uuid:- $ref: '#/components/schemas/UUIDv4'- description:+ VideoBlacklistCreate:+ type: object+ properties:+ reason:type: string- minLength: 3- maxLength: 10000- duration:- type: integer- views:- type: integer- likes:- type: integer- dislikes:- type: integer- nsfw:+ description: Reason for the block (public)+ unfederate:type: boolean+ description: Whether to unfederate the video+ internalNote:+ type: string+ description: Internal note for moderators/admins+ VideoBlacklistUpdate:+ type: object+ properties:+ reason:+ type: string+ description: Reason for the block (displayed publicly)+ internalNote:+ type: string+ description: Internal note for moderators/adminsChangeOwnership:type: objectdescription: Representation of a ownership change