import {
AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Is, Model, Scopes, Table,
- UpdatedAt, Default
+ UpdatedAt, Default, DataType
} from 'sequelize-typescript'
import { ActivityPubActor } from '../../../shared/models/activitypub'
import { VideoChannel } from '../../../shared/models/videos'
import { ActorModel } from '../activitypub/actor'
import { getSort, throwIfNotValid } from '../utils'
import { VideoModel } from './video'
+import { CONSTRAINTS_FIELDS } from '../../initializers'
+import { AvatarModel } from '../avatar/avatar'
enum ScopeNames {
WITH_ACCOUNT = 'WITH_ACCOUNT',
[ScopeNames.WITH_ACCOUNT]: {
include: [
{
- model: () => AccountModel,
+ model: () => AccountModel.unscoped(),
required: true,
include: [
{
- model: () => ActorModel,
- required: true
+ model: () => ActorModel.unscoped(),
+ required: true,
+ include: [
+ {
+ model: () => AvatarModel.unscoped(),
+ required: false
+ }
+ ]
}
]
}
@AllowNull(true)
@Default(null)
@Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description'))
- @Column
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max))
description: string
@AllowNull(true)
@Default(null)
@Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support'))
- @Column
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max))
support: string
@CreatedAt
const actor = this.Actor.toFormattedJSON()
const videoChannel = {
id: this.id,
- displayName: this.name,
+ displayName: this.getDisplayName(),
description: this.description,
support: this.support,
isLocal: this.Actor.isOwned(),
videos: undefined
}
- if (this.Account) {
- videoChannel.ownerAccount = {
- id: this.Account.id,
- uuid: this.Account.Actor.uuid
- }
- }
+ if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()
return Object.assign(actor, videoChannel)
}
]
})
}
+
+ getDisplayName () {
+ return this.name
+ }
}