diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-26 10:55:40 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (patch) | |
tree | 5e9bc5604fd5d66a006cfebb7acdbdd5486e5d1e /server/lib/activitypub/process/process-create.ts | |
parent | b427febb4d5cebf03b815bca2c59af6e82491569 (diff) | |
download | PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.gz PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.zst PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.zip |
Playlist server API
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 5f4d793a5..e882669ce 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -12,6 +12,8 @@ import { Notifier } from '../../notifier' | |||
12 | import { processViewActivity } from './process-view' | 12 | import { processViewActivity } from './process-view' |
13 | import { processDislikeActivity } from './process-dislike' | 13 | 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' | ||
16 | import { createOrUpdateVideoPlaylist } from '../playlist' | ||
15 | 17 | ||
16 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { | 18 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { |
17 | const activityObject = activity.object | 19 | const activityObject = activity.object |
@@ -38,7 +40,11 @@ async function processCreateActivity (activity: ActivityCreate, byActor: ActorMo | |||
38 | } | 40 | } |
39 | 41 | ||
40 | if (activityType === 'CacheFile') { | 42 | if (activityType === 'CacheFile') { |
41 | return retryTransactionWrapper(processCacheFile, activity, byActor) | 43 | return retryTransactionWrapper(processCreateCacheFile, activity, byActor) |
44 | } | ||
45 | |||
46 | if (activityType === 'Playlist') { | ||
47 | return retryTransactionWrapper(processCreatePlaylist, activity, byActor) | ||
42 | } | 48 | } |
43 | 49 | ||
44 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) | 50 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) |
@@ -63,7 +69,7 @@ async function processCreateVideo (activity: ActivityCreate) { | |||
63 | return video | 69 | return video |
64 | } | 70 | } |
65 | 71 | ||
66 | async function processCacheFile (activity: ActivityCreate, byActor: ActorModel) { | 72 | async function processCreateCacheFile (activity: ActivityCreate, byActor: ActorModel) { |
67 | const cacheFile = activity.object as CacheFileObject | 73 | const cacheFile = activity.object as CacheFileObject |
68 | 74 | ||
69 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFile.object }) | 75 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFile.object }) |
@@ -98,3 +104,12 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act | |||
98 | 104 | ||
99 | if (created === true) Notifier.Instance.notifyOnNewComment(comment) | 105 | if (created === true) Notifier.Instance.notifyOnNewComment(comment) |
100 | } | 106 | } |
107 | |||
108 | async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) { | ||
109 | const playlistObject = activity.object as PlaylistObject | ||
110 | const byAccount = byActor.Account | ||
111 | |||
112 | if (!byAccount) throw new Error('Cannot create video playlist with the non account actor ' + byActor.url) | ||
113 | |||
114 | await createOrUpdateVideoPlaylist(playlistObject, byAccount, activity.to) | ||
115 | } | ||