From 47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Jan 2018 10:12:36 +0100 Subject: Add ability to disable video comments --- server/models/video/video.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/models/video/video.ts') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 2504ae58a..c4b716cd2 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -15,9 +15,10 @@ import { Video, VideoDetails } from '../../../shared/models/videos' import { activityPubCollection } from '../../helpers/activitypub' import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' +import { isBooleanValid } from '../../helpers/custom-validators/misc' import { isVideoCategoryValid, isVideoDescriptionValid, isVideoDurationValid, isVideoLanguageValid, isVideoLicenceValid, isVideoNameValid, - isVideoNSFWValid, isVideoPrivacyValid + isVideoPrivacyValid } from '../../helpers/custom-validators/videos' import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' import { logger } from '../../helpers/logger' @@ -185,7 +186,7 @@ export class VideoModel extends Model { privacy: number @AllowNull(false) - @Is('VideoNSFW', value => throwIfNotValid(value, isVideoNSFWValid, 'NSFW boolean')) + @Is('VideoNSFW', value => throwIfNotValid(value, isBooleanValid, 'NSFW boolean')) @Column nsfw: boolean @@ -230,6 +231,10 @@ export class VideoModel extends Model { @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max)) url: string + @AllowNull(false) + @Column + commentsEnabled: boolean + @CreatedAt createdAt: Date @@ -773,6 +778,7 @@ export class VideoModel extends Model { channel: this.VideoChannel.toFormattedJSON(), account: this.VideoChannel.Account.toFormattedJSON(), tags: map(this.Tags, 'name'), + commentsEnabled: this.commentsEnabled, files: [] } @@ -920,6 +926,7 @@ export class VideoModel extends Model { language, views: this.views, nsfw: this.nsfw, + commentsEnabled: this.commentsEnabled, published: this.createdAt.toISOString(), updated: this.updatedAt.toISOString(), mediaType: 'text/markdown', -- cgit v1.2.3