diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-03 10:12:36 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-03 10:38:19 +0100 |
commit | 47564bbe2eeb2baae9b7e3f9b2b8d16522bc7e04 (patch) | |
tree | 25e2836baf3dfce6f422192d98332db1bfe65890 /server/models | |
parent | c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (diff) | |
download | PeerTube-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.ts | 4 | ||||
-rw-r--r-- | server/models/avatar/avatar.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 11 |
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 @@ | |||
1 | import { values } from 'lodash' | 1 | import { values } from 'lodash' |
2 | import { extname, join } from 'path' | 2 | import { extname } from 'path' |
3 | import * as Sequelize from 'sequelize' | 3 | import * as Sequelize from 'sequelize' |
4 | import { | 4 | import { |
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' |
15 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 15 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
16 | import { ACTIVITY_PUB_ACTOR_TYPES, AVATARS_DIR, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 16 | import { ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' |
17 | import { AccountModel } from '../account/account' | 17 | import { AccountModel } from '../account/account' |
18 | import { AvatarModel } from '../avatar/avatar' | 18 | import { AvatarModel } from '../avatar/avatar' |
19 | import { ServerModel } from '../server/server' | 19 | 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' | |||
2 | import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' | 2 | import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' |
3 | import { Avatar } from '../../../shared/models/avatars/avatar.model' | 3 | import { Avatar } from '../../../shared/models/avatars/avatar.model' |
4 | import { unlinkPromise } from '../../helpers/core-utils' | 4 | import { unlinkPromise } from '../../helpers/core-utils' |
5 | import { logger } from '../../helpers/logger' | ||
6 | import { CONFIG, STATIC_PATHS } from '../../initializers' | 5 | import { CONFIG, STATIC_PATHS } from '../../initializers' |
7 | import { 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' | |||
15 | import { activityPubCollection } from '../../helpers/activitypub' | 15 | import { activityPubCollection } from '../../helpers/activitypub' |
16 | import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils' | 16 | import { createTorrentPromise, renamePromise, statPromise, unlinkPromise, writeFilePromise } from '../../helpers/core-utils' |
17 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 17 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
18 | import { isBooleanValid } from '../../helpers/custom-validators/misc' | ||
18 | import { | 19 | import { |
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' |
22 | import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' | 23 | import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' |
23 | import { logger } from '../../helpers/logger' | 24 | import { 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', |