aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-update.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-02 11:54:29 +0200
committerChocobozzz <me@florianbigard.com>2021-06-02 16:57:53 +0200
commitc56faf0d9453490737f283b29a203bb1ca632b95 (patch)
tree6f6f92ae762921112e49cf5a440381053bb5a492 /server/lib/activitypub/process/process-update.ts
parent08a47c75f992e7138dca5121f227909a8347d365 (diff)
downloadPeerTube-c56faf0d9453490737f283b29a203bb1ca632b95.tar.gz
PeerTube-c56faf0d9453490737f283b29a203bb1ca632b95.tar.zst
PeerTube-c56faf0d9453490737f283b29a203bb1ca632b95.zip
Move AP video channel creation
Diffstat (limited to 'server/lib/activitypub/process/process-update.ts')
-rw-r--r--server/lib/activitypub/process/process-update.ts23
1 files changed, 6 insertions, 17 deletions
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index de1ff5d90..516bd8d70 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -12,12 +12,12 @@ import { AccountModel } from '../../../models/account/account'
12import { ActorModel } from '../../../models/actor/actor' 12import { ActorModel } from '../../../models/actor/actor'
13import { VideoChannelModel } from '../../../models/video/video-channel' 13import { VideoChannelModel } from '../../../models/video/video-channel'
14import { APProcessorOptions } from '../../../types/activitypub-processor.model' 14import { APProcessorOptions } from '../../../types/activitypub-processor.model'
15import { MAccountIdActor, MActorSignature } from '../../../types/models' 15import { MActorSignature } from '../../../types/models'
16import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor' 16import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor'
17import { createOrUpdateCacheFile } from '../cache-file' 17import { createOrUpdateCacheFile } from '../cache-file'
18import { createOrUpdateVideoPlaylist } from '../playlist' 18import { createOrUpdateVideoPlaylist } from '../playlist'
19import { forwardVideoRelatedActivity } from '../send/utils' 19import { forwardVideoRelatedActivity } from '../send/utils'
20import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, APVideoUpdater } from '../videos' 20import { APVideoUpdater, getOrCreateVideoAndAccountAndChannel } from '../videos'
21 21
22async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) { 22async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) {
23 const { activity, byActor } = options 23 const { activity, byActor } = options
@@ -25,7 +25,7 @@ async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate
25 const objectType = activity.object.type 25 const objectType = activity.object.type
26 26
27 if (objectType === 'Video') { 27 if (objectType === 'Video') {
28 return retryTransactionWrapper(processUpdateVideo, byActor, activity) 28 return retryTransactionWrapper(processUpdateVideo, activity)
29 } 29 }
30 30
31 if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') { 31 if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') {
@@ -55,7 +55,7 @@ export {
55 55
56// --------------------------------------------------------------------------- 56// ---------------------------------------------------------------------------
57 57
58async function processUpdateVideo (actor: MActorSignature, activity: ActivityUpdate) { 58async function processUpdateVideo (activity: ActivityUpdate) {
59 const videoObject = activity.object as VideoObject 59 const videoObject = activity.object as VideoObject
60 60
61 if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) { 61 if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) {
@@ -71,19 +71,8 @@ async function processUpdateVideo (actor: MActorSignature, activity: ActivityUpd
71 // We did not have this video, it has been created so no need to update 71 // We did not have this video, it has been created so no need to update
72 if (created) return 72 if (created) return
73 73
74 // Load new channel 74 const updater = new APVideoUpdater(videoObject, video)
75 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject) 75 return updater.update(activity.to)
76
77 const account = actor.Account as MAccountIdActor
78 account.Actor = actor
79
80 const updater = new APVideoUpdater({
81 video,
82 videoObject,
83 channel: channelActor.VideoChannel,
84 overrideTo: activity.to
85 })
86 return updater.update()
87} 76}
88 77
89async function processUpdateCacheFile (byActor: MActorSignature, activity: ActivityUpdate) { 78async function processUpdateCacheFile (byActor: MActorSignature, activity: ActivityUpdate) {