From e024fd6a7494b37251da1d59470324305cdb4129 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 7 May 2021 17:14:39 +0200 Subject: Update channel updatedAt when uploading a video --- server/models/video/video-channel.ts | 8 +++++++- server/models/video/video.ts | 7 ++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index b627595c9..081b21f2d 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,6 +17,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { setAsUpdated } from '@server/helpers/database-utils' import { MAccountActor } from '@server/types/models' import { ActivityPubActor } from '../../../shared/models/activitypub' import { VideoChannel, VideoChannelSummary } from '../../../shared/models/videos' @@ -653,6 +654,7 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` description: this.description, support: this.support, isLocal: this.Actor.isOwned(), + updatedAt: this.updatedAt, ownerAccount: undefined, videosCount, viewsPerDay @@ -689,4 +691,8 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` isOutdated () { return this.Actor.isOutdated() } + + setAsUpdated (transaction: Transaction) { + return setAsUpdated('videoChannel', this.id, transaction) + } } diff --git a/server/models/video/video.ts b/server/models/video/video.ts index e55a21a6b..8c316e00c 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -24,6 +24,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { setAsUpdated } from '@server/helpers/database-utils' import { buildNSFWFilter } from '@server/helpers/express-utils' import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' import { LiveManager } from '@server/lib/live-manager' @@ -2053,11 +2054,7 @@ export class VideoModel extends Model { } setAsRefreshed () { - const options = { - where: { id: this.id } - } - - return VideoModel.update({ updatedAt: new Date() }, options) + return setAsUpdated('video', this.id) } requiresAuth () { -- cgit v1.2.3