diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-02 11:54:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-02 16:57:53 +0200 |
commit | c56faf0d9453490737f283b29a203bb1ca632b95 (patch) | |
tree | 6f6f92ae762921112e49cf5a440381053bb5a492 /server/lib/activitypub/process/process-update.ts | |
parent | 08a47c75f992e7138dca5121f227909a8347d365 (diff) | |
download | PeerTube-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.ts | 23 |
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' | |||
12 | import { ActorModel } from '../../../models/actor/actor' | 12 | import { ActorModel } from '../../../models/actor/actor' |
13 | import { VideoChannelModel } from '../../../models/video/video-channel' | 13 | import { VideoChannelModel } from '../../../models/video/video-channel' |
14 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' | 14 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' |
15 | import { MAccountIdActor, MActorSignature } from '../../../types/models' | 15 | import { MActorSignature } from '../../../types/models' |
16 | import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor' | 16 | import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor' |
17 | import { createOrUpdateCacheFile } from '../cache-file' | 17 | import { createOrUpdateCacheFile } from '../cache-file' |
18 | import { createOrUpdateVideoPlaylist } from '../playlist' | 18 | import { createOrUpdateVideoPlaylist } from '../playlist' |
19 | import { forwardVideoRelatedActivity } from '../send/utils' | 19 | import { forwardVideoRelatedActivity } from '../send/utils' |
20 | import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, APVideoUpdater } from '../videos' | 20 | import { APVideoUpdater, getOrCreateVideoAndAccountAndChannel } from '../videos' |
21 | 21 | ||
22 | async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) { | 22 | async 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 | ||
58 | async function processUpdateVideo (actor: MActorSignature, activity: ActivityUpdate) { | 58 | async 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 | ||
89 | async function processUpdateCacheFile (byActor: MActorSignature, activity: ActivityUpdate) { | 78 | async function processUpdateCacheFile (byActor: MActorSignature, activity: ActivityUpdate) { |