Fix ownership change
authorChocobozzz <me@florianbigard.com>
Wed, 21 Aug 2019 06:57:00 +0000 (08:57 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 21 Aug 2019 06:57:00 +0000 (08:57 +0200)
server/lib/activitypub/process/process-update.ts
server/lib/activitypub/videos.ts
server/tests/api/videos/video-change-ownership.ts
server/typings/models/account/account.ts

index 9f80a0ce9cb95219637d435b6caf4666b10d3bee..a47d605d82fbf6b4d5c1434f710f0529488ba054 100644 (file)
@@ -15,7 +15,7 @@ import { forwardVideoRelatedActivity } from '../send/utils'
 import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
 import { createOrUpdateVideoPlaylist } from '../playlist'
 import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-import { MActorSignature } from '../../../typings/models'
+import { MActorSignature, MAccountIdActor } from '../../../typings/models'
 
 async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) {
   const { activity, byActor } = options
@@ -64,10 +64,13 @@ async function processUpdateVideo (actor: MActorSignature, activity: ActivityUpd
   const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id, allowRefresh: false, fetchType: 'all' })
   const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
 
+  const account = actor.Account as MAccountIdActor
+  account.Actor = actor
+
   const updateOptions = {
     video,
     videoObject,
-    account: channelActor.VideoChannel.Account,
+    account,
     channel: channelActor.VideoChannel,
     overrideTo: activity.to
   }
index 970a953fc43a4363efd36f112fda019528d52adc..c318978fd4fbeb4310b8eacff032e5ffa76ef062 100644 (file)
@@ -53,13 +53,13 @@ import { FilteredModelAttributes } from '../../typings/sequelize'
 import { autoBlacklistVideoIfNeeded } from '../video-blacklist'
 import { ActorFollowScoreCache } from '../files-cache'
 import {
-  MAccountActor,
+  MAccountIdActor,
   MChannelAccountLight,
   MChannelDefault,
   MChannelId,
   MVideo,
-  MVideoAccountLightBlacklistAllFiles,
   MVideoAccountLight,
+  MVideoAccountLightBlacklistAllFiles,
   MVideoAP,
   MVideoAPWithoutCaption,
   MVideoFile,
@@ -265,7 +265,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
 async function updateVideoFromAP (options: {
   video: MVideoAccountLightBlacklistAllFiles,
   videoObject: VideoTorrentObject,
-  account: MAccountActor,
+  account: MAccountIdActor,
   channel: MChannelDefault,
   overrideTo?: string[]
 }) {
index 3a3add71b099cd744ca44e3d56fc309f7e71edbd..64ee2355af24ad2020623be4db5c626cc416caff 100644 (file)
@@ -191,7 +191,7 @@ describe('Test video change ownership - nominal', function () {
     await waitJobs(servers)
   })
 
-  it('Should have video channel updated', async function () {
+  it('Should have the channel of the video updated', async function () {
     for (const server of servers) {
       const res = await getVideo(server.url, servers[0].video.uuid)
 
index 33940517eafb54ad6afc81be04da29c837c3c39a..cd20fe81b4da2b2841859f6a37e0b4e4821c922b 100644 (file)
@@ -1,17 +1,16 @@
 import { AccountModel } from '../../../models/account/account'
 import {
   MActor,
-  MActorAccountChannelId,
   MActorAPI,
   MActorAudience,
   MActorDefault,
   MActorDefaultLight,
+  MActorFormattable,
   MActorId,
   MActorServer,
   MActorSummary,
   MActorSummaryFormattable,
-  MActorUrl,
-  MActorFormattable
+  MActorUrl
 } from './actor'
 import { FunctionProperties, PickWith } from '../../utils'
 import { MAccountBlocklistId } from './account-blocklist'
@@ -35,7 +34,7 @@ export type MAccountUrl = Use<'Actor', MActorUrl>
 export type MAccountAudience = Use<'Actor', MActorAudience>
 
 export type MAccountIdActor = MAccountId &
-  Use<'Actor', MActorAccountChannelId>
+  Use<'Actor', MActor>
 
 export type MAccountIdActorId = MAccountId &
   Use<'Actor', MActorId>