From 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Dec 2017 17:53:50 +0100 Subject: Move models to typescript-sequelize --- server/lib/activitypub/video-channels.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'server/lib/activitypub/video-channels.ts') 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 @@ -import { VideoChannelObject } from '../../../shared/models/activitypub/objects/video-channel-object' -import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub/video-channels' -import { logger } from '../../helpers/logger' -import { doRequest } from '../../helpers/requests' -import { database as db } from '../../initializers' -import { ACTIVITY_PUB } from '../../initializers/constants' -import { AccountInstance } from '../../models/account/account-interface' +import { VideoChannelObject } from '../../../shared/models/activitypub/objects' +import { doRequest, logger } from '../../helpers' +import { isVideoChannelObjectValid } from '../../helpers/custom-validators/activitypub' +import { ACTIVITY_PUB } from '../../initializers' +import { AccountModel } from '../../models/account/account' +import { VideoChannelModel } from '../../models/video/video-channel' import { videoChannelActivityObjectToDBAttributes } from './process/misc' -async function getOrCreateVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { - let videoChannel = await db.VideoChannel.loadByUrl(videoChannelUrl) +async function getOrCreateVideoChannel (ownerAccount: AccountModel, videoChannelUrl: string) { + let videoChannel = await VideoChannelModel.loadByUrl(videoChannelUrl) // We don't have this account in our database, fetch it on remote if (!videoChannel) { @@ -22,7 +21,7 @@ async function getOrCreateVideoChannel (ownerAccount: AccountInstance, videoChan return videoChannel } -async function fetchRemoteVideoChannel (ownerAccount: AccountInstance, videoChannelUrl: string) { +async function fetchRemoteVideoChannel (ownerAccount: AccountModel, videoChannelUrl: string) { const options = { uri: videoChannelUrl, method: 'GET', @@ -48,7 +47,7 @@ async function fetchRemoteVideoChannel (ownerAccount: AccountInstance, videoChan } const videoChannelAttributes = videoChannelActivityObjectToDBAttributes(videoChannelJSON, ownerAccount) - const videoChannel = db.VideoChannel.build(videoChannelAttributes) + const videoChannel = new VideoChannelModel(videoChannelAttributes) videoChannel.Account = ownerAccount return videoChannel -- cgit v1.2.3