X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=4e98e7ba3f064333176f8a30c2e87c98365c7518;hb=0374b6b5cd685316f924874b2a3068bb345eb0dd;hp=7a4df516aa55b388e5b9a610431e9475a7c41451;hpb=1ca9f7c3f7afac2af4c4c25b98426731f7e789c6;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 7a4df516a..4e98e7ba3 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -37,21 +37,12 @@ import * as Bluebird from 'bluebird' import { MChannelAccountDefault, MChannelActor, - MChannelActorAccountDefaultVideos, MChannelSummaryFormattable, MChannelFormattable + 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 -const indexes: ModelIndexesOptions[] = [ - buildTrigramSearchIndex('video_channel_name_trigram', 'name'), - - { - fields: [ 'accountId' ] - }, - { - fields: [ 'actorId' ] - } -] - export enum ScopeNames { FOR_API = 'FOR_API', WITH_ACCOUNT = 'WITH_ACCOUNT', @@ -173,7 +164,16 @@ export type SummaryOptions = { })) @Table({ tableName: 'videoChannel', - indexes + indexes: [ + buildTrigramSearchIndex('video_channel_name_trigram', 'name'), + + { + fields: [ 'accountId' ] + }, + { + fields: [ 'actorId' ] + } + ] }) export class VideoChannelModel extends Model { @@ -246,7 +246,7 @@ export class VideoChannelModel extends Model { @BeforeDestroy static async sendDeleteIfOwned (instance: VideoChannelModel, options) { if (!instance.Actor) { - instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel + instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) } if (instance.Actor.isOwned()) { @@ -513,8 +513,8 @@ export class VideoChannelModel extends Model { return Object.assign(actor, videoChannel) } - toActivityPubObject (): ActivityPubActor { - const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel') + toActivityPubObject (this: MChannelAP): ActivityPubActor { + const obj = this.Actor.toActivityPubObject(this.name) return Object.assign(obj, { summary: this.description,