import { processViewActivity } from './process-view'
import { processDislikeActivity } from './process-dislike'
import { processFlagActivity } from './process-flag'
+import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
+import { createOrUpdateVideoPlaylist } from '../playlist'
async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) {
const activityObject = activity.object
}
if (activityType === 'CacheFile') {
- return retryTransactionWrapper(processCacheFile, activity, byActor)
+ return retryTransactionWrapper(processCreateCacheFile, activity, byActor)
+ }
+
+ if (activityType === 'Playlist') {
+ return retryTransactionWrapper(processCreatePlaylist, activity, byActor)
}
logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id })
return video
}
-async function processCacheFile (activity: ActivityCreate, byActor: ActorModel) {
+async function processCreateCacheFile (activity: ActivityCreate, byActor: ActorModel) {
const cacheFile = activity.object as CacheFileObject
const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFile.object })
if (created === true) Notifier.Instance.notifyOnNewComment(comment)
}
+
+async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) {
+ const playlistObject = activity.object as PlaylistObject
+ const byAccount = byActor.Account
+
+ if (!byAccount) throw new Error('Cannot create video playlist with the non account actor ' + byActor.url)
+
+ await createOrUpdateVideoPlaylist(playlistObject, byAccount, activity.to)
+}