From f92e7f76d43cbad173be87f47105b9a02032318a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Aug 2019 08:57:00 +0200 Subject: Fix ownership change --- server/lib/activitypub/process/process-update.ts | 7 +++++-- server/lib/activitypub/videos.ts | 6 +++--- server/tests/api/videos/video-change-ownership.ts | 2 +- server/typings/models/account/account.ts | 7 +++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 9f80a0ce9..a47d605d8 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts @@ -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) { 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 } diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 970a953fc..c318978fd 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -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[] }) { diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 3a3add71b..64ee2355a 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts @@ -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) diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts index 33940517e..cd20fe81b 100644 --- a/server/typings/models/account/account.ts +++ b/server/typings/models/account/account.ts @@ -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> -- cgit v1.2.3