X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=33749ea70fef997ce20c346b9f61fbf0e599ceff;hb=eae0365b5c5468e51e9795b0e894815ebda86b4a;hp=b7ffbd3b136f5bde0f2f55be3aec2e99f2e4dcd2;hpb=4024c44f9027a32809931de0692d40d001df721c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index b7ffbd3b1..33749ea70 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -1,4 +1,4 @@ -import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions } from 'sequelize' +import { FindOptions, Includeable, literal, Op, QueryTypes, ScopeOptions, Transaction } from 'sequelize' import { AllowNull, BeforeDestroy, @@ -17,7 +17,9 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { setAsUpdated } from '@server/helpers/database-utils' import { MAccountActor } from '@server/types/models' +import { AttributesOnly } from '@shared/core-utils' import { ActivityPubActor } from '../../../shared/models/activitypub' import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos' import { @@ -35,9 +37,9 @@ import { MChannelSummaryFormattable } from '../../types/models/video' import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' -import { ActorImageModel } from '../account/actor-image' -import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' -import { ActorFollowModel } from '../activitypub/actor-follow' +import { ActorModel, unusedActorAttributesForAPI } from '../actor/actor' +import { ActorFollowModel } from '../actor/actor-follow' +import { ActorImageModel } from '../actor/actor-image' import { ServerModel } from '../server/server' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' @@ -245,7 +247,7 @@ export type SummaryOptions = { } ] }) -export class VideoChannelModel extends Model { +export class VideoChannelModel extends Model>> { @AllowNull(false) @Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelNameValid, 'name')) @@ -520,10 +522,10 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` }) } - static loadAndPopulateAccount (id: number): Promise { + static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise { return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ]) - .findByPk(id) + .findByPk(id, { transaction }) } static loadByUrlAndPopulateAccount (url: string): Promise { @@ -653,7 +655,6 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` description: this.description, support: this.support, isLocal: this.Actor.isOwned(), - createdAt: this.createdAt, updatedAt: this.updatedAt, ownerAccount: undefined, videosCount, @@ -691,4 +692,8 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` isOutdated () { return this.Actor.isOutdated() } + + setAsUpdated (transaction: Transaction) { + return setAsUpdated('videoChannel', this.id, transaction) + } }