aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-03 10:12:36 +0100
committerChocobozzz <me@florianbigard.com>2018-01-03 10:38:19 +0100
commit47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04 (patch)
tree25e2836baf3dfce6f422192d98332db1bfe65890 /server/models
parentc5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (diff)
downloadPeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.gz
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.tar.zst
PeerTube-47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04.zip
Add ability to disable video comments
Diffstat (limited to 'server/models')
-rw-r--r--server/models/activitypub/actor.ts4
-rw-r--r--server/models/avatar/avatar.ts2
-rw-r--r--server/models/video/video.ts11
3 files changed, 11 insertions, 6 deletions
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 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import { extname, join } from 'path' 2import { extname } from 'path'
3import * as Sequelize from 'sequelize' 3import * as Sequelize from 'sequelize'
4import { 4import {
5 AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, DefaultScope, ForeignKey, HasMany, HasOne, Is, IsUUID, Model, Scopes, 5 AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, DefaultScope, ForeignKey, HasMany, HasOne, Is, IsUUID, Model, Scopes,
@@ -13,7 +13,7 @@ import {
13 isActorPublicKeyValid 13 isActorPublicKeyValid
14} from '../../helpers/custom-validators/activitypub/actor' 14} from '../../helpers/custom-validators/activitypub/actor'
15import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 15import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
16import { ACTIVITY_PUB_ACTOR_TYPES, AVATARS_DIR, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' 16import { ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
17import { AccountModel } from '../account/account' 17import { AccountModel } from '../account/account'
18import { AvatarModel } from '../avatar/avatar' 18import { AvatarModel } from '../avatar/avatar'
19import { ServerModel } from '../server/server' 19import { 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'
2import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' 2import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript'
3import { Avatar } from '../../../shared/models/avatars/avatar.model' 3import { Avatar } from '../../../shared/models/avatars/avatar.model'
4import { unlinkPromise } from '../../helpers/core-utils' 4import { unlinkPromise } from '../../helpers/core-utils'
5import { logger } from '../../helpers/logger'
6import { CONFIG, STATIC_PATHS } from '../../initializers' 5import { CONFIG, STATIC_PATHS } from '../../initializers'
7import { sendDeleteVideo } from '../../lib/activitypub/send'
8 6
9@Table({ 7@Table({
10 tableName: 'avatar' 8 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'
15import { activityPubCollection } from '../../helpers/activitypub' 15import { activityPubCollection } from '../../helpers/activitypub'
16import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils' 16import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils'
17import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 17import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
18import { isBooleanValid } from '../../helpers/custom-validators/misc'
18import { 19import {
19 isVideoCategoryValid, isVideoDescriptionValid, isVideoDurationValid, isVideoLanguageValid, isVideoLicenceValid, isVideoNameValid, 20 isVideoCategoryValid, isVideoDescriptionValid, isVideoDurationValid, isVideoLanguageValid, isVideoLicenceValid, isVideoNameValid,
20 isVideoNSFWValid, isVideoPrivacyValid 21 isVideoPrivacyValid
21} from '../../helpers/custom-validators/videos' 22} from '../../helpers/custom-validators/videos'
22import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' 23import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils'
23import { logger } from '../../helpers/logger' 24import { logger } from '../../helpers/logger'
@@ -185,7 +186,7 @@ export class VideoModel extends Model<VideoModel> {
185 privacy: number 186 privacy: number
186 187
187 @AllowNull(false) 188 @AllowNull(false)
188 @Is('VideoNSFW', value => throwIfNotValid(value, isVideoNSFWValid, 'NSFW boolean')) 189 @Is('VideoNSFW', value => throwIfNotValid(value, isBooleanValid, 'NSFW boolean'))
189 @Column 190 @Column
190 nsfw: boolean 191 nsfw: boolean
191 192
@@ -230,6 +231,10 @@ export class VideoModel extends Model<VideoModel> {
230 @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max)) 231 @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max))
231 url: string 232 url: string
232 233
234 @AllowNull(false)
235 @Column
236 commentsEnabled: boolean
237
233 @CreatedAt 238 @CreatedAt
234 createdAt: Date 239 createdAt: Date
235 240
@@ -773,6 +778,7 @@ export class VideoModel extends Model<VideoModel> {
773 channel: this.VideoChannel.toFormattedJSON(), 778 channel: this.VideoChannel.toFormattedJSON(),
774 account: this.VideoChannel.Account.toFormattedJSON(), 779 account: this.VideoChannel.Account.toFormattedJSON(),
775 tags: map<TagModel, string>(this.Tags, 'name'), 780 tags: map<TagModel, string>(this.Tags, 'name'),
781 commentsEnabled: this.commentsEnabled,
776 files: [] 782 files: []
777 } 783 }
778 784
@@ -920,6 +926,7 @@ export class VideoModel extends Model<VideoModel> {
920 language, 926 language,
921 views: this.views, 927 views: this.views,
922 nsfw: this.nsfw, 928 nsfw: this.nsfw,
929 commentsEnabled: this.commentsEnabled,
923 published: this.createdAt.toISOString(), 930 published: this.createdAt.toISOString(),
924 updated: this.updatedAt.toISOString(), 931 updated: this.updatedAt.toISOString(),
925 mediaType: 'text/markdown', 932 mediaType: 'text/markdown',