aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-13 10:06:50 +0200
committerChocobozzz <me@florianbigard.com>2018-06-13 10:22:53 +0200
commit3cd0734fd9b0ff21aaef02317a874e8f1c06e027 (patch)
tree9e8622d269919addd35b462141ab5f22236aa6f4 /server/lib/activitypub
parent2186386cca113506791583cb07d6ccacba7af4e0 (diff)
downloadPeerTube-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.ts14
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 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { ActivityUpdate } from '../../../../shared/models/activitypub' 2import { ActivityUpdate, VideoTorrentObject } from '../../../../shared/models/activitypub'
3import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' 3import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor'
4import { retryTransactionWrapper } from '../../../helpers/database-utils' 4import { retryTransactionWrapper } from '../../../helpers/database-utils'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
@@ -12,13 +12,13 @@ import { VideoChannelModel } from '../../../models/video/video-channel'
12import { VideoFileModel } from '../../../models/video/video-file' 12import { VideoFileModel } from '../../../models/video/video-file'
13import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor' 13import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor'
14import { 14import {
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'
21import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
22 22
23async function processUpdateActivity (activity: ActivityUpdate) { 23async 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
53async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { 53async 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