diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-31 15:14:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-31 15:17:04 +0200 |
commit | ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a (patch) | |
tree | d18b7f8667ee41923c89744586c1b71b8691f4a2 /server/lib/activitypub/process | |
parent | 57cfff78858b2360d9e038e2a504b761cb51da47 (diff) | |
download | PeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.tar.gz PeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.tar.zst PeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.zip |
More robust federation
In particular when fetching pleroma outbox
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 15 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 13 |
2 files changed, 25 insertions, 3 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 23310b41e..bbf1bd3a8 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -5,8 +5,9 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
5 | import { VideoShareModel } from '../../../models/video/video-share' | 5 | import { VideoShareModel } from '../../../models/video/video-share' |
6 | import { forwardVideoRelatedActivity } from '../send/utils' | 6 | import { forwardVideoRelatedActivity } from '../send/utils' |
7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
8 | import { VideoPrivacy } from '../../../../shared/models/videos' | ||
9 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { VideoModel } from '../../../models/video/video' | ||
10 | import { logger } from '../../../helpers/logger' | ||
10 | 11 | ||
11 | async function processAnnounceActivity (activity: ActivityAnnounce, actorAnnouncer: ActorModel) { | 12 | async function processAnnounceActivity (activity: ActivityAnnounce, actorAnnouncer: ActorModel) { |
12 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity) | 13 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity) |
@@ -23,7 +24,17 @@ export { | |||
23 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { | 24 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { |
24 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id | 25 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id |
25 | 26 | ||
26 | const { video, created: videoCreated } = await getOrCreateVideoAndAccountAndChannel({ videoObject: objectUri }) | 27 | let video: VideoModel |
28 | let videoCreated: boolean | ||
29 | |||
30 | try { | ||
31 | const result = await getOrCreateVideoAndAccountAndChannel({ videoObject: objectUri }) | ||
32 | video = result.video | ||
33 | videoCreated = result.created | ||
34 | } catch (err) { | ||
35 | logger.debug('Cannot process share of %s. Maybe this is not a video object, so just skipping.', objectUri, { err }) | ||
36 | return | ||
37 | } | ||
27 | 38 | ||
28 | await sequelizeTypescript.transaction(async t => { | 39 | await sequelizeTypescript.transaction(async t => { |
29 | // Add share entry | 40 | // Add share entry |
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index e882669ce..e4c173e99 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -14,6 +14,7 @@ import { processDislikeActivity } from './process-dislike' | |||
14 | import { processFlagActivity } from './process-flag' | 14 | import { processFlagActivity } from './process-flag' |
15 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | 15 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' |
16 | import { createOrUpdateVideoPlaylist } from '../playlist' | 16 | import { createOrUpdateVideoPlaylist } from '../playlist' |
17 | import { VideoModel } from '../../../models/video/video' | ||
17 | 18 | ||
18 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { | 19 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { |
19 | const activityObject = activity.object | 20 | const activityObject = activity.object |
@@ -91,7 +92,17 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act | |||
91 | 92 | ||
92 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) | 93 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) |
93 | 94 | ||
94 | const { video } = await resolveThread(commentObject.inReplyTo) | 95 | let video: VideoModel |
96 | try { | ||
97 | const resolveThreadResult = await resolveThread(commentObject.inReplyTo) | ||
98 | video = resolveThreadResult.video | ||
99 | } catch (err) { | ||
100 | logger.debug( | ||
101 | 'Cannot process video comment because we could not resolve thread %s. Maybe it was not a video thread, so skip it.', | ||
102 | commentObject.inReplyTo, | ||
103 | { err } | ||
104 | ) | ||
105 | } | ||
95 | 106 | ||
96 | const { comment, created } = await addVideoComment(video, commentObject.id) | 107 | const { comment, created } = await addVideoComment(video, commentObject.id) |
97 | 108 | ||