diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-13 10:06:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-13 10:22:53 +0200 |
commit | 3cd0734fd9b0ff21aaef02317a874e8f1c06e027 (patch) | |
tree | 9e8622d269919addd35b462141ab5f22236aa6f4 /server/lib/activitypub | |
parent | 2186386cca113506791583cb07d6ccacba7af4e0 (diff) | |
download | PeerTube-3cd0734fd9b0ff21aaef02317a874e8f1c06e027.tar.gz PeerTube-3cd0734fd9b0ff21aaef02317a874e8f1c06e027.tar.zst PeerTube-3cd0734fd9b0ff21aaef02317a874e8f1c06e027.zip |
Improve tests when waiting pending jobs
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 77de8c155..1ebda46d3 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { ActivityUpdate } from '../../../../shared/models/activitypub' | 2 | import { ActivityUpdate, VideoTorrentObject } from '../../../../shared/models/activitypub' |
3 | import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' | 3 | import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' |
4 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 4 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
@@ -12,13 +12,13 @@ import { VideoChannelModel } from '../../../models/video/video-channel' | |||
12 | import { VideoFileModel } from '../../../models/video/video-file' | 12 | import { VideoFileModel } from '../../../models/video/video-file' |
13 | import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor' | 13 | import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor' |
14 | import { | 14 | import { |
15 | fetchRemoteVideo, | ||
16 | generateThumbnailFromUrl, | 15 | generateThumbnailFromUrl, |
17 | getOrCreateAccountAndVideoAndChannel, | 16 | getOrCreateAccountAndVideoAndChannel, |
18 | getOrCreateVideoChannel, | 17 | getOrCreateVideoChannel, |
19 | videoActivityObjectToDBAttributes, | 18 | videoActivityObjectToDBAttributes, |
20 | videoFileActivityUrlToDBAttributes | 19 | videoFileActivityUrlToDBAttributes |
21 | } from '../videos' | 20 | } from '../videos' |
21 | import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' | ||
22 | 22 | ||
23 | async function processUpdateActivity (activity: ActivityUpdate) { | 23 | async function processUpdateActivity (activity: ActivityUpdate) { |
24 | const actor = await getOrCreateActorAndServerAndModel(activity.actor) | 24 | const actor = await getOrCreateActorAndServerAndModel(activity.actor) |
@@ -30,7 +30,7 @@ async function processUpdateActivity (activity: ActivityUpdate) { | |||
30 | return processUpdateActor(actor, activity) | 30 | return processUpdateActor(actor, activity) |
31 | } | 31 | } |
32 | 32 | ||
33 | return | 33 | return undefined |
34 | } | 34 | } |
35 | 35 | ||
36 | // --------------------------------------------------------------------------- | 36 | // --------------------------------------------------------------------------- |
@@ -51,10 +51,12 @@ function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { | 53 | async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { |
54 | const videoUrl = activity.object.id | 54 | const videoObject = activity.object as VideoTorrentObject |
55 | 55 | ||
56 | const videoObject = await fetchRemoteVideo(videoUrl) | 56 | if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) { |
57 | if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl) | 57 | logger.debug('Video sent by update is not valid.', { videoObject }) |
58 | return undefined | ||
59 | } | ||
58 | 60 | ||
59 | const res = await getOrCreateAccountAndVideoAndChannel(videoObject.id) | 61 | const res = await getOrCreateAccountAndVideoAndChannel(videoObject.id) |
60 | 62 | ||