More robust channel change federation
This commit is contained in:
parent
23ac334389
commit
92315d979c
|
@ -62,7 +62,15 @@ async function processUpdateVideo (actor: MActorSignature, activity: ActivityUpd
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id, allowRefresh: false, fetchType: 'all' })
|
const { video, created } = await getOrCreateVideoAndAccountAndChannel({
|
||||||
|
videoObject: videoObject.id,
|
||||||
|
allowRefresh: false,
|
||||||
|
fetchType: 'all'
|
||||||
|
})
|
||||||
|
// We did not have this video, it has been created so no need to update
|
||||||
|
if (created) return
|
||||||
|
|
||||||
|
// Load new channel
|
||||||
const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
|
const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
|
||||||
|
|
||||||
const account = actor.Account as MAccountIdActor
|
const account = actor.Account as MAccountIdActor
|
||||||
|
|
|
@ -336,10 +336,15 @@ async function updateVideoFromAP (options: {
|
||||||
|
|
||||||
videoFieldsSave = video.toJSON()
|
videoFieldsSave = video.toJSON()
|
||||||
|
|
||||||
// Check actor has the right to update the video
|
// Check we can update the channel: we trust the remote server
|
||||||
const videoChannel = video.VideoChannel
|
const oldVideoChannel = video.VideoChannel
|
||||||
if (videoChannel.Account.id !== account.id) {
|
|
||||||
throw new Error('Account ' + account.Actor.url + ' does not own video channel ' + videoChannel.Actor.url)
|
if (!oldVideoChannel.Actor.serverId || !channel.Actor.serverId) {
|
||||||
|
throw new Error('Cannot check old channel/new channel validity because `serverId` is null')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldVideoChannel.Actor.serverId !== channel.Actor.serverId) {
|
||||||
|
throw new Error('New channel ' + channel.Actor.url + ' is not on the same server than new channel ' + oldVideoChannel.Actor.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const to = overrideTo || videoObject.to
|
const to = overrideTo || videoObject.to
|
||||||
|
|
Loading…
Reference in New Issue