diff options
Diffstat (limited to 'server/lib/activitypub/video-channels.ts')
-rw-r--r-- | server/lib/activitypub/video-channels.ts | 21 |
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 @@ | |||
1 | import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' | 1 | import { VideoChannelObject } from '../../../shared/models/activitypub/objects' |
2 | import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub/video-channels' | 2 | import { doRequest, logger } from '../../helpers' |
3 | import { logger } from '../../helpers/logger' | 3 | import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub' |
4 | import { doRequest } from '../../helpers/requests' | 4 | import { ACTIVITY_PUB } from '../../initializers' |
5 | import { database as db } from '../../initializers' | 5 | import { AccountModel } from '../../models/account/account' |
6 | import { ACTIVITY_PUB } from '../../initializers/constants' | 6 | import { VideoChannelModel } from '../../models/video/video-channel' |
7 | import { AccountInstance } from '../../models/account/account-interface' | ||
8 | import { videoChannelActivityObjectToDBAttributes } from './process/misc' | 7 | import { videoChannelActivityObjectToDBAttributes } from './process/misc' |
9 | 8 | ||
10 | async function getOrCreateVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { | 9 | async 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 | ||
25 | async function fetchRemoteVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { | 24 | async 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 |