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/activitypub/actor.ts | 4 ++-- server/models/avatar/avatar.ts | 2 -- server/models/video/video.ts | 11 +++++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'server/models') diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 8422653df..a12f3ec9e 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -1,5 +1,5 @@ import { values } from 'lodash' -import { extname, join } from 'path' +import { extname } from 'path' import * as Sequelize from 'sequelize' import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, DefaultScope, ForeignKey, HasMany, HasOne, Is, IsUUID, Model, Scopes, @@ -13,7 +13,7 @@ import { isActorPublicKeyValid } from '../../helpers/custom-validators/activitypub/actor' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { ACTIVITY_PUB_ACTOR_TYPES, AVATARS_DIR, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' +import { ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' import { AccountModel } from '../account/account' import { AvatarModel } from '../avatar/avatar' import { ServerModel } from '../server/server' diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts index 7493c3d75..e1d4c20bc 100644 --- a/server/models/avatar/avatar.ts +++ b/server/models/avatar/avatar.ts @@ -2,9 +2,7 @@ import { join } from 'path' import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' import { Avatar } from '../../../shared/models/avatars/avatar.model' import { unlinkPromise } from '../../helpers/core-utils' -import { logger } from '../../helpers/logger' import { CONFIG, STATIC_PATHS } from '../../initializers' -import { sendDeleteVideo } from '../../lib/activitypub/send' @Table({ tableName: 'avatar' 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