From 2422c46b27790d94fd29a7092170cee5a1b56008 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Feb 2018 14:46:26 +0100 Subject: Implement support field in video and video channel --- server/models/video/video-channel.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'server/models/video/video-channel.ts') 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 @@ import { AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table, - UpdatedAt + UpdatedAt, Default } from 'sequelize-typescript' import { ActivityPubActor } from '../../../shared/models/activitypub' -import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' +import { VideoChannel } from '../../../shared/models/videos' +import { + isVideoChannelDescriptionValid, isVideoChannelNameValid, + isVideoChannelSupportValid +} from '../../helpers/custom-validators/video-channels' import { logger } from '../../helpers/logger' import { sendDeleteActor } from '../../lib/activitypub/send' import { AccountModel } from '../account/account' @@ -67,10 +71,17 @@ export class VideoChannelModel extends Model { name: string @AllowNull(true) + @Default(null) @Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description')) @Column description: string + @AllowNull(true) + @Default(null) + @Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support')) + @Column + support: string + @CreatedAt createdAt: Date @@ -221,12 +232,13 @@ export class VideoChannelModel extends Model { .findById(id, options) } - toFormattedJSON () { + toFormattedJSON (): VideoChannel { const actor = this.Actor.toFormattedJSON() const account = { id: this.id, displayName: this.name, description: this.description, + support: this.support, isLocal: this.Actor.isOwned(), createdAt: this.createdAt, updatedAt: this.updatedAt @@ -240,6 +252,7 @@ export class VideoChannelModel extends Model { return Object.assign(obj, { summary: this.description, + support: this.support, attributedTo: [ { type: 'Person' as 'Person', -- cgit v1.2.3