mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Fix missing transactions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { Transaction } from 'sequelize'
|
||||
import { AllowNull, Column, CreatedAt, Default, HasMany, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
||||
import { MServer, MServerFormattable } from '@server/types/models/server'
|
||||
import { AttributesOnly } from '@shared/core-utils'
|
||||
@@ -51,11 +52,12 @@ export class ServerModel extends Model<Partial<AttributesOnly<ServerModel>>> {
|
||||
})
|
||||
BlockedByAccounts: ServerBlocklistModel[]
|
||||
|
||||
static load (id: number): Promise<MServer> {
|
||||
static load (id: number, transaction?: Transaction): Promise<MServer> {
|
||||
const query = {
|
||||
where: {
|
||||
id
|
||||
}
|
||||
},
|
||||
transaction
|
||||
}
|
||||
|
||||
return ServerModel.findOne(query)
|
||||
|
||||
@@ -91,9 +91,9 @@ export class VideoCaptionModel extends Model<Partial<AttributesOnly<VideoCaption
|
||||
Video: VideoModel
|
||||
|
||||
@BeforeDestroy
|
||||
static async removeFiles (instance: VideoCaptionModel) {
|
||||
static async removeFiles (instance: VideoCaptionModel, options) {
|
||||
if (!instance.Video) {
|
||||
instance.Video = await instance.$get('Video')
|
||||
instance.Video = await instance.$get('Video', { transaction: options.transaction })
|
||||
}
|
||||
|
||||
if (instance.isOwned()) {
|
||||
@@ -113,8 +113,7 @@ export class VideoCaptionModel extends Model<Partial<AttributesOnly<VideoCaption
|
||||
const videoInclude = {
|
||||
model: VideoModel.unscoped(),
|
||||
attributes: [ 'id', 'remote', 'uuid' ],
|
||||
where: buildWhereIdOrUUID(videoId),
|
||||
transaction
|
||||
where: buildWhereIdOrUUID(videoId)
|
||||
}
|
||||
|
||||
const query = {
|
||||
@@ -123,7 +122,8 @@ export class VideoCaptionModel extends Model<Partial<AttributesOnly<VideoCaption
|
||||
},
|
||||
include: [
|
||||
videoInclude
|
||||
]
|
||||
],
|
||||
transaction
|
||||
}
|
||||
|
||||
return VideoCaptionModel.findOne(query)
|
||||
|
||||
@@ -522,10 +522,10 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"`
|
||||
})
|
||||
}
|
||||
|
||||
static loadAndPopulateAccount (id: number): Promise<MChannelBannerAccountDefault> {
|
||||
static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise<MChannelBannerAccountDefault> {
|
||||
return VideoChannelModel.unscoped()
|
||||
.scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ])
|
||||
.findByPk(id)
|
||||
.findByPk(id, { transaction })
|
||||
}
|
||||
|
||||
static loadByUrlAndPopulateAccount (url: string): Promise<MChannelBannerAccountDefault> {
|
||||
|
||||
@@ -739,6 +739,12 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment
|
||||
return this.Account.isOwned()
|
||||
}
|
||||
|
||||
markAsDeleted () {
|
||||
this.text = ''
|
||||
this.deletedAt = new Date()
|
||||
this.accountId = null
|
||||
}
|
||||
|
||||
isDeleted () {
|
||||
return this.deletedAt !== null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user