diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-10 17:18:12 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-10 17:19:14 +0100 |
commit | 2ccaeeb341ffe8c2609039bf4c6d8835b4650316 (patch) | |
tree | a6bf6e05e7f02bc315e872d67a0b61ad6ad3d777 /server/lib/activitypub/process/process-announce.ts | |
parent | 759f8a29e95932023564ca98dcbc90d1acb92da0 (diff) | |
download | PeerTube-2ccaeeb341ffe8c2609039bf4c6d8835b4650316.tar.gz PeerTube-2ccaeeb341ffe8c2609039bf4c6d8835b4650316.tar.zst PeerTube-2ccaeeb341ffe8c2609039bf4c6d8835b4650316.zip |
Fetch remote AP objects
Diffstat (limited to 'server/lib/activitypub/process/process-announce.ts')
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 9adb40e01..bf7d7879d 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -7,6 +7,7 @@ import { VideoModel } from '../../../models/video/video' | |||
7 | import { VideoShareModel } from '../../../models/video/video-share' | 7 | import { VideoShareModel } from '../../../models/video/video-share' |
8 | import { getOrCreateActorAndServerAndModel } from '../actor' | 8 | import { getOrCreateActorAndServerAndModel } from '../actor' |
9 | import { forwardActivity } from '../send/misc' | 9 | import { forwardActivity } from '../send/misc' |
10 | import { getOrCreateAccountAndVideoAndChannel } from '../videos' | ||
10 | import { processCreateActivity } from './process-create' | 11 | import { processCreateActivity } from './process-create' |
11 | 12 | ||
12 | async function processAnnounceActivity (activity: ActivityAnnounce) { | 13 | async function processAnnounceActivity (activity: ActivityAnnounce) { |
@@ -44,19 +45,19 @@ function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnoun | |||
44 | return retryTransactionWrapper(shareVideo, options) | 45 | return retryTransactionWrapper(shareVideo, options) |
45 | } | 46 | } |
46 | 47 | ||
47 | function shareVideo (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { | 48 | async function shareVideo (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { |
48 | const announced = activity.object | 49 | const announced = activity.object |
50 | let video: VideoModel | ||
51 | |||
52 | if (typeof announced === 'string') { | ||
53 | const res = await getOrCreateAccountAndVideoAndChannel(announced) | ||
54 | video = res.video | ||
55 | } else { | ||
56 | video = await processCreateActivity(announced) | ||
57 | } | ||
49 | 58 | ||
50 | return sequelizeTypescript.transaction(async t => { | 59 | return sequelizeTypescript.transaction(async t => { |
51 | // Add share entry | 60 | // Add share entry |
52 | let video: VideoModel | ||
53 | |||
54 | if (typeof announced === 'string') { | ||
55 | video = await VideoModel.loadByUrlAndPopulateAccount(announced) | ||
56 | if (!video) throw new Error('Unknown video to share ' + announced) | ||
57 | } else { | ||
58 | video = await processCreateActivity(announced) | ||
59 | } | ||
60 | 61 | ||
61 | const share = { | 62 | const share = { |
62 | actorId: actorAnnouncer.id, | 63 | actorId: actorAnnouncer.id, |