Fix hooks definition
This commit is contained in:
parent
693c6586cb
commit
06c2759338
|
@ -22,7 +22,9 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
|
|||
|
||||
// Send to origin
|
||||
if (video.isOwned() === false) {
|
||||
const accountActor = (video as MVideoAccountLight).VideoChannel?.Account?.Actor || await ActorModel.loadAccountActorByVideoId(video.id)
|
||||
let accountActor: MActorLight = (video as MVideoAccountLight).VideoChannel?.Account?.Actor
|
||||
|
||||
if (!accountActor) accountActor = await ActorModel.loadAccountActorByVideoId(video.id, transaction)
|
||||
|
||||
const audience = getRemoteVideoAudience(accountActor, actorsInvolvedInVideo)
|
||||
const activity = activityBuilder(audience)
|
||||
|
|
|
@ -496,7 +496,7 @@ export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
|
|||
}, { where, transaction })
|
||||
}
|
||||
|
||||
static loadAccountActorByVideoId (videoId: number): Promise<MActor> {
|
||||
static loadAccountActorByVideoId (videoId: number, transaction: Transaction): Promise<MActor> {
|
||||
const query = {
|
||||
include: [
|
||||
{
|
||||
|
@ -520,7 +520,8 @@ export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
|
|||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
transaction
|
||||
}
|
||||
|
||||
return ActorModel.unscoped().findOne(query)
|
||||
|
|
|
@ -291,8 +291,7 @@ export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannel
|
|||
@BelongsTo(() => AccountModel, {
|
||||
foreignKey: {
|
||||
allowNull: false
|
||||
},
|
||||
hooks: true
|
||||
}
|
||||
})
|
||||
Account: AccountModel
|
||||
|
||||
|
|
|
@ -572,7 +572,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
|
|||
foreignKey: {
|
||||
allowNull: true
|
||||
},
|
||||
hooks: true,
|
||||
onDelete: 'cascade'
|
||||
})
|
||||
VideoChannel: VideoChannelModel
|
||||
|
|
|
@ -8,6 +8,7 @@ import { HttpStatusCode } from '@shared/core-utils'
|
|||
import {
|
||||
buildAbsoluteFixturePath,
|
||||
buildServerDirectory,
|
||||
cleanupTests,
|
||||
flushAndRunServer,
|
||||
getMyUserInformation,
|
||||
prepareResumableUpload,
|
||||
|
@ -184,4 +185,7 @@ describe('Test resumable upload', function () {
|
|||
})
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await cleanupTests([ server ])
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
getVideoChannel,
|
||||
getVideoChannelVideos,
|
||||
setDefaultVideoChannel,
|
||||
testFileExistsOrNot,
|
||||
testImage,
|
||||
updateVideo,
|
||||
updateVideoChannelImage,
|
||||
|
@ -53,6 +54,9 @@ describe('Test video channels', function () {
|
|||
let videoUUID: string
|
||||
let accountName: string
|
||||
|
||||
const avatarPaths: { [ port: number ]: string } = {}
|
||||
const bannerPaths: { [ port: number ]: string } = {}
|
||||
|
||||
before(async function () {
|
||||
this.timeout(60000)
|
||||
|
||||
|
@ -287,9 +291,11 @@ describe('Test video channels', function () {
|
|||
for (const server of servers) {
|
||||
const videoChannel = await findChannel(server, secondVideoChannelId)
|
||||
|
||||
await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png')
|
||||
avatarPaths[server.port] = videoChannel.avatar.path
|
||||
await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png')
|
||||
await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true)
|
||||
|
||||
const row = await getActorImage(server.internalServerNumber, basename(videoChannel.avatar.path))
|
||||
const row = await getActorImage(server.internalServerNumber, basename(avatarPaths[server.port]))
|
||||
expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height)
|
||||
expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width)
|
||||
}
|
||||
|
@ -314,9 +320,11 @@ describe('Test video channels', function () {
|
|||
const res = await getVideoChannel(server.url, 'second_video_channel@' + servers[0].host)
|
||||
const videoChannel = res.body
|
||||
|
||||
await testImage(server.url, 'banner-resized', videoChannel.banner.path)
|
||||
bannerPaths[server.port] = videoChannel.banner.path
|
||||
await testImage(server.url, 'banner-resized', bannerPaths[server.port])
|
||||
await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true)
|
||||
|
||||
const row = await getActorImage(server.internalServerNumber, basename(videoChannel.banner.path))
|
||||
const row = await getActorImage(server.internalServerNumber, basename(bannerPaths[server.port]))
|
||||
expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height)
|
||||
expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width)
|
||||
}
|
||||
|
@ -336,6 +344,7 @@ describe('Test video channels', function () {
|
|||
|
||||
for (const server of servers) {
|
||||
const videoChannel = await findChannel(server, secondVideoChannelId)
|
||||
await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), false)
|
||||
|
||||
expect(videoChannel.avatar).to.be.null
|
||||
}
|
||||
|
@ -355,6 +364,7 @@ describe('Test video channels', function () {
|
|||
|
||||
for (const server of servers) {
|
||||
const videoChannel = await findChannel(server, secondVideoChannelId)
|
||||
await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), false)
|
||||
|
||||
expect(videoChannel.banner).to.be.null
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as chai from 'chai'
|
||||
import * as ffmpeg from 'fluent-ffmpeg'
|
||||
import { ensureDir, pathExists, readFile, stat } from 'fs-extra'
|
||||
import { ensureDir, exists, pathExists, readFile, stat } from 'fs-extra'
|
||||
import { basename, dirname, isAbsolute, join, resolve } from 'path'
|
||||
import * as request from 'supertest'
|
||||
import * as WebTorrent from 'webtorrent'
|
||||
|
@ -60,8 +60,14 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
|
|||
const minLength = body.length - ((30 * body.length) / 100)
|
||||
const maxLength = body.length + ((30 * body.length) / 100)
|
||||
|
||||
expect(data.length).to.be.above(minLength, "the generated image is way smaller than the recorded fixture")
|
||||
expect(data.length).to.be.below(maxLength, "the generated image is way larger than the recorded fixture")
|
||||
expect(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture')
|
||||
expect(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture')
|
||||
}
|
||||
|
||||
async function testFileExistsOrNot (server: { internalServerNumber: number }, directory: string, filePath: string, exist: boolean) {
|
||||
const base = buildServerDirectory(server, directory)
|
||||
|
||||
expect(await pathExists(join(base, filePath))).to.equal(exist)
|
||||
}
|
||||
|
||||
function isGithubCI () {
|
||||
|
@ -157,6 +163,7 @@ export {
|
|||
testImage,
|
||||
isGithubCI,
|
||||
buildAbsoluteFixturePath,
|
||||
testFileExistsOrNot,
|
||||
root,
|
||||
generateHighBitrateVideo,
|
||||
generateVideoWithFramerate
|
||||
|
|
Loading…
Reference in New Issue