aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/video-channels.ts')
-rw-r--r--server/lib/activitypub/video-channels.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/server/lib/activitypub/video-channels.ts b/server/lib/activitypub/video-channels.ts
index 7339d79f9..c05a46f95 100644
--- a/server/lib/activitypub/video-channels.ts
+++ b/server/lib/activitypub/video-channels.ts
@@ -1,14 +1,13 @@
1import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' 1import { VideoChannelObject } from '../../../shared/models/activitypub/objects'
2import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub/video-channels' 2import { doRequest, logger } from '../../helpers'
3import { logger } from '../../helpers/logger' 3import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub'
4import { doRequest } from '../../helpers/requests' 4import { ACTIVITY_PUB } from '../../initializers'
5import { database as db } from '../../initializers' 5import { AccountModel } from '../../models/account/account'
6import { ACTIVITY_PUB } from '../../initializers/constants' 6import { VideoChannelModel } from '../../models/video/video-channel'
7import { AccountInstance } from '../../models/account/account-interface'
8import { videoChannelActivityObjectToDBAttributes } from './process/misc' 7import { videoChannelActivityObjectToDBAttributes } from './process/misc'
9 8
10async function getOrCreateVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { 9async function getOrCreateVideoChannel (ownerAccount: AccountModel, videoChannelUrl: string) {
11 let videoChannel = await db.VideoChannel.loadByUrl(videoChannelUrl) 10 let videoChannel = await VideoChannelModel.loadByUrl(videoChannelUrl)
12 11
13 // We don't have this account in our database, fetch it on remote 12 // We don't have this account in our database, fetch it on remote
14 if (!videoChannel) { 13 if (!videoChannel) {
@@ -22,7 +21,7 @@ async function getOrCreateVideoChannel (ownerAccount: AccountInstance, videoChan
22 return videoChannel 21 return videoChannel
23} 22}
24 23
25async function fetchRemoteVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { 24async function fetchRemoteVideoChannel (ownerAccount: AccountModel, videoChannelUrl: string) {
26 const options = { 25 const options = {
27 uri: videoChannelUrl, 26 uri: videoChannelUrl,
28 method: 'GET', 27 method: 'GET',
@@ -48,7 +47,7 @@ async function fetchRemoteVideoChannel (ownerAccount: AccountInstance, videoChan
48 } 47 }
49 48
50 const videoChannelAttributes = videoChannelActivityObjectToDBAttributes(videoChannelJSON, ownerAccount) 49 const videoChannelAttributes = videoChannelActivityObjectToDBAttributes(videoChannelJSON, ownerAccount)
51 const videoChannel = db.VideoChannel.build(videoChannelAttributes) 50 const videoChannel = new VideoChannelModel(videoChannelAttributes)
52 videoChannel.Account = ownerAccount 51 videoChannel.Account = ownerAccount
53 52
54 return videoChannel 53 return videoChannel