import {
MChannelAccountDefault,
MChannelActor,
- MChannelActorAccountDefault,
- MChannelActorAccountDefaultVideos
+ MChannelActorAccountDefaultVideos,
+ MChannelAP,
+ MChannelFormattable,
+ MChannelSummaryFormattable
} from '../../typings/models/video'
// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
})
}
- static loadByIdAndPopulateAccount (id: number): Bluebird<MChannelActorAccountDefault> {
+ static loadByIdAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> {
return VideoChannelModel.unscoped()
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
.findByPk(id)
}
- static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelActorAccountDefault> {
+ static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelAccountDefault> {
const query = {
where: {
id,
.findOne(query)
}
- static loadAndPopulateAccount (id: number): Bluebird<MChannelActorAccountDefault> {
+ static loadAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> {
return VideoChannelModel.unscoped()
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
.findByPk(id)
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
}
- static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelActorAccountDefault> {
+ static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelAccountDefault> {
const query = {
include: [
{
.findOne(query)
}
- static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelActorAccountDefault> {
+ static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelAccountDefault> {
const query = {
include: [
{
.findByPk(id, options)
}
- toFormattedJSON (): VideoChannel {
+ toFormattedSummaryJSON (this: MChannelSummaryFormattable): VideoChannelSummary {
+ const actor = this.Actor.toFormattedSummaryJSON()
+
+ return {
+ id: this.id,
+ name: actor.name,
+ displayName: this.getDisplayName(),
+ url: actor.url,
+ host: actor.host,
+ avatar: actor.avatar
+ }
+ }
+
+ toFormattedJSON (this: MChannelFormattable): VideoChannel {
const actor = this.Actor.toFormattedJSON()
const videoChannel = {
id: this.id,
return Object.assign(actor, videoChannel)
}
- toFormattedSummaryJSON (): VideoChannelSummary {
- const actor = this.Actor.toFormattedJSON()
-
- return {
- id: this.id,
- name: actor.name,
- displayName: this.getDisplayName(),
- url: actor.url,
- host: actor.host,
- avatar: actor.avatar
- }
- }
-
- toActivityPubObject (): ActivityPubActor {
+ toActivityPubObject (this: MChannelAP): ActivityPubActor {
const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel')
return Object.assign(obj, {