aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-15 14:46:26 +0100
committerChocobozzz <me@florianbigard.com>2018-02-15 15:29:07 +0100
commit2422c46b27790d94fd29a7092170cee5a1b56008 (patch)
treed5c1942ce20cadb27a551d87c789edfe92f5b105 /server/models/video/video-channel.ts
parent34cbef8c6cc912143a421413bdd832c4adcc556a (diff)
downloadPeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst
PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip
Implement support field in video and video channel
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 7c161c864..289775a0f 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -1,9 +1,13 @@
1import { 1import {
2 AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table, 2 AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table,
3 UpdatedAt 3 UpdatedAt, Default
4} from 'sequelize-typescript' 4} from 'sequelize-typescript'
5import { ActivityPubActor } from '../../../shared/models/activitypub' 5import { ActivityPubActor } from '../../../shared/models/activitypub'
6import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' 6import { VideoChannel } from '../../../shared/models/videos'
7import {
8 isVideoChannelDescriptionValid, isVideoChannelNameValid,
9 isVideoChannelSupportValid
10} from '../../helpers/custom-validators/video-channels'
7import { logger } from '../../helpers/logger' 11import { logger } from '../../helpers/logger'
8import { sendDeleteActor } from '../../lib/activitypub/send' 12import { sendDeleteActor } from '../../lib/activitypub/send'
9import { AccountModel } from '../account/account' 13import { AccountModel } from '../account/account'
@@ -67,10 +71,17 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
67 name: string 71 name: string
68 72
69 @AllowNull(true) 73 @AllowNull(true)
74 @Default(null)
70 @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description')) 75 @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description'))
71 @Column 76 @Column
72 description: string 77 description: string
73 78
79 @AllowNull(true)
80 @Default(null)
81 @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support'))
82 @Column
83 support: string
84
74 @CreatedAt 85 @CreatedAt
75 createdAt: Date 86 createdAt: Date
76 87
@@ -221,12 +232,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
221 .findById(id, options) 232 .findById(id, options)
222 } 233 }
223 234
224 toFormattedJSON () { 235 toFormattedJSON (): VideoChannel {
225 const actor = this.Actor.toFormattedJSON() 236 const actor = this.Actor.toFormattedJSON()
226 const account = { 237 const account = {
227 id: this.id, 238 id: this.id,
228 displayName: this.name, 239 displayName: this.name,
229 description: this.description, 240 description: this.description,
241 support: this.support,
230 isLocal: this.Actor.isOwned(), 242 isLocal: this.Actor.isOwned(),
231 createdAt: this.createdAt, 243 createdAt: this.createdAt,
232 updatedAt: this.updatedAt 244 updatedAt: this.updatedAt
@@ -240,6 +252,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
240 252
241 return Object.assign(obj, { 253 return Object.assign(obj, {
242 summary: this.description, 254 summary: this.description,
255 support: this.support,
243 attributedTo: [ 256 attributedTo: [
244 { 257 {
245 type: 'Person' as 'Person', 258 type: 'Person' as 'Person',