aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/send/utils.ts4
-rw-r--r--server/models/actor/actor.ts5
-rw-r--r--server/models/video/video-channel.ts3
-rw-r--r--server/models/video/video.ts1
-rw-r--r--server/tests/api/videos/resumable-upload.ts4
-rw-r--r--server/tests/api/videos/video-channels.ts18
6 files changed, 25 insertions, 10 deletions
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts
index db0e91b71..7cd8030e1 100644
--- a/server/lib/activitypub/send/utils.ts
+++ b/server/lib/activitypub/send/utils.ts
@@ -22,7 +22,9 @@ async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAud
22 22
23 // Send to origin 23 // Send to origin
24 if (video.isOwned() === false) { 24 if (video.isOwned() === false) {
25 const accountActor = (video as MVideoAccountLight).VideoChannel?.Account?.Actor || await ActorModel.loadAccountActorByVideoId(video.id) 25 let accountActor: MActorLight = (video as MVideoAccountLight).VideoChannel?.Account?.Actor
26
27 if (!accountActor) accountActor = await ActorModel.loadAccountActorByVideoId(video.id, transaction)
26 28
27 const audience = getRemoteVideoAudience(accountActor, actorsInvolvedInVideo) 29 const audience = getRemoteVideoAudience(accountActor, actorsInvolvedInVideo)
28 const activity = activityBuilder(audience) 30 const activity = activityBuilder(audience)
diff --git a/server/models/actor/actor.ts b/server/models/actor/actor.ts
index 0cd30f545..8df49951d 100644
--- a/server/models/actor/actor.ts
+++ b/server/models/actor/actor.ts
@@ -496,7 +496,7 @@ export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
496 }, { where, transaction }) 496 }, { where, transaction })
497 } 497 }
498 498
499 static loadAccountActorByVideoId (videoId: number): Promise<MActor> { 499 static loadAccountActorByVideoId (videoId: number, transaction: Transaction): Promise<MActor> {
500 const query = { 500 const query = {
501 include: [ 501 include: [
502 { 502 {
@@ -520,7 +520,8 @@ export class ActorModel extends Model<Partial<AttributesOnly<ActorModel>>> {
520 } 520 }
521 ] 521 ]
522 } 522 }
523 ] 523 ],
524 transaction
524 } 525 }
525 526
526 return ActorModel.unscoped().findOne(query) 527 return ActorModel.unscoped().findOne(query)
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index f84b85290..183e7448c 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -291,8 +291,7 @@ export class VideoChannelModel extends Model<Partial<AttributesOnly<VideoChannel
291 @BelongsTo(() => AccountModel, { 291 @BelongsTo(() => AccountModel, {
292 foreignKey: { 292 foreignKey: {
293 allowNull: false 293 allowNull: false
294 }, 294 }
295 hooks: true
296 }) 295 })
297 Account: AccountModel 296 Account: AccountModel
298 297
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 7a9e96210..1e5648a36 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -572,7 +572,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
572 foreignKey: { 572 foreignKey: {
573 allowNull: true 573 allowNull: true
574 }, 574 },
575 hooks: true,
576 onDelete: 'cascade' 575 onDelete: 'cascade'
577 }) 576 })
578 VideoChannel: VideoChannelModel 577 VideoChannel: VideoChannelModel
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index af9221c43..4fc3317df 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -8,6 +8,7 @@ import { HttpStatusCode } from '@shared/core-utils'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 buildServerDirectory, 10 buildServerDirectory,
11 cleanupTests,
11 flushAndRunServer, 12 flushAndRunServer,
12 getMyUserInformation, 13 getMyUserInformation,
13 prepareResumableUpload, 14 prepareResumableUpload,
@@ -184,4 +185,7 @@ describe('Test resumable upload', function () {
184 }) 185 })
185 }) 186 })
186 187
188 after(async function () {
189 await cleanupTests([ server ])
190 })
187}) 191})
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 7e7ad028c..865098777 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -15,6 +15,7 @@ import {
15 getVideoChannel, 15 getVideoChannel,
16 getVideoChannelVideos, 16 getVideoChannelVideos,
17 setDefaultVideoChannel, 17 setDefaultVideoChannel,
18 testFileExistsOrNot,
18 testImage, 19 testImage,
19 updateVideo, 20 updateVideo,
20 updateVideoChannelImage, 21 updateVideoChannelImage,
@@ -53,6 +54,9 @@ describe('Test video channels', function () {
53 let videoUUID: string 54 let videoUUID: string
54 let accountName: string 55 let accountName: string
55 56
57 const avatarPaths: { [ port: number ]: string } = {}
58 const bannerPaths: { [ port: number ]: string } = {}
59
56 before(async function () { 60 before(async function () {
57 this.timeout(60000) 61 this.timeout(60000)
58 62
@@ -287,9 +291,11 @@ describe('Test video channels', function () {
287 for (const server of servers) { 291 for (const server of servers) {
288 const videoChannel = await findChannel(server, secondVideoChannelId) 292 const videoChannel = await findChannel(server, secondVideoChannelId)
289 293
290 await testImage(server.url, 'avatar-resized', videoChannel.avatar.path, '.png') 294 avatarPaths[server.port] = videoChannel.avatar.path
295 await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png')
296 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true)
291 297
292 const row = await getActorImage(server.internalServerNumber, basename(videoChannel.avatar.path)) 298 const row = await getActorImage(server.internalServerNumber, basename(avatarPaths[server.port]))
293 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height) 299 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height)
294 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width) 300 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width)
295 } 301 }
@@ -314,9 +320,11 @@ describe('Test video channels', function () {
314 const res = await getVideoChannel(server.url, 'second_video_channel@' + servers[0].host) 320 const res = await getVideoChannel(server.url, 'second_video_channel@' + servers[0].host)
315 const videoChannel = res.body 321 const videoChannel = res.body
316 322
317 await testImage(server.url, 'banner-resized', videoChannel.banner.path) 323 bannerPaths[server.port] = videoChannel.banner.path
324 await testImage(server.url, 'banner-resized', bannerPaths[server.port])
325 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true)
318 326
319 const row = await getActorImage(server.internalServerNumber, basename(videoChannel.banner.path)) 327 const row = await getActorImage(server.internalServerNumber, basename(bannerPaths[server.port]))
320 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height) 328 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height)
321 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width) 329 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width)
322 } 330 }
@@ -336,6 +344,7 @@ describe('Test video channels', function () {
336 344
337 for (const server of servers) { 345 for (const server of servers) {
338 const videoChannel = await findChannel(server, secondVideoChannelId) 346 const videoChannel = await findChannel(server, secondVideoChannelId)
347 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), false)
339 348
340 expect(videoChannel.avatar).to.be.null 349 expect(videoChannel.avatar).to.be.null
341 } 350 }
@@ -355,6 +364,7 @@ describe('Test video channels', function () {
355 364
356 for (const server of servers) { 365 for (const server of servers) {
357 const videoChannel = await findChannel(server, secondVideoChannelId) 366 const videoChannel = await findChannel(server, secondVideoChannelId)
367 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), false)
358 368
359 expect(videoChannel.banner).to.be.null 369 expect(videoChannel.banner).to.be.null
360 } 370 }