From 892211e8493b1f992fce7616cb1e48b7ff87a1dc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 20 Nov 2017 10:24:29 +0100 Subject: Move activitypub functions from helpers/ to lib/ --- server/lib/activitypub/process/process-add.ts | 17 +++++++++-------- server/lib/activitypub/process/process-announce.ts | 2 +- server/lib/activitypub/process/process-create.ts | 3 ++- server/lib/activitypub/process/process-delete.ts | 2 +- server/lib/activitypub/process/process-follow.ts | 3 ++- server/lib/activitypub/process/process-update.ts | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) (limited to 'server/lib/activitypub/process') diff --git a/server/lib/activitypub/process/process-add.ts b/server/lib/activitypub/process/process-add.ts index f064c1ab6..281036228 100644 --- a/server/lib/activitypub/process/process-add.ts +++ b/server/lib/activitypub/process/process-add.ts @@ -1,11 +1,14 @@ import * as Bluebird from 'bluebird' import { VideoTorrentObject } from '../../../../shared' import { ActivityAdd } from '../../../../shared/models/activitypub/activity' -import { generateThumbnailFromUrl, getOrCreateAccount, logger, retryTransactionWrapper } from '../../../helpers' -import { getOrCreateVideoChannel } from '../../../helpers/activitypub' +import { retryTransactionWrapper } from '../../../helpers/database-utils' +import { logger } from '../../../helpers/logger' import { database as db } from '../../../initializers' import { AccountInstance } from '../../../models/account/account-interface' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' +import { getOrCreateAccount } from '../account' +import { getOrCreateVideoChannel } from '../video-channels' +import { generateThumbnailFromUrl } from '../videos' import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' async function processAddActivity (activity: ActivityAdd) { @@ -41,12 +44,10 @@ function processAddVideo (account: AccountInstance, activity: ActivityAdd, video return retryTransactionWrapper(addRemoteVideo, options) } -function addRemoteVideo ( - account: AccountInstance, - activity: ActivityAdd, - videoChannel: VideoChannelInstance, - videoToCreateData: VideoTorrentObject -) { +function addRemoteVideo (account: AccountInstance, + activity: ActivityAdd, + videoChannel: VideoChannelInstance, + videoToCreateData: VideoTorrentObject) { logger.debug('Adding remote video %s.', videoToCreateData.url) return db.sequelize.transaction(async t => { diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 656db08a9..40712ef03 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts @@ -1,11 +1,11 @@ import { ActivityAnnounce } from '../../../../shared/models/activitypub/activity' -import { getOrCreateAccount } from '../../../helpers/activitypub' import { logger } from '../../../helpers/logger' import { database as db } from '../../../initializers/index' import { VideoInstance } from '../../../models/index' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' import { processAddActivity } from './process-add' import { processCreateActivity } from './process-create' +import { getOrCreateAccount } from '../account' async function processAnnounceActivity (activity: ActivityAnnounce) { const announcedActivity = activity.object diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index aac941a6c..fc635eb1f 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -1,9 +1,10 @@ import { ActivityCreate, VideoChannelObject } from '../../../../shared' import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects/video-abuse-object' import { logger, retryTransactionWrapper } from '../../../helpers' -import { getOrCreateAccount, getVideoChannelActivityPubUrl } from '../../../helpers/activitypub' import { database as db } from '../../../initializers' import { AccountInstance } from '../../../models/account/account-interface' +import { getOrCreateAccount } from '../account' +import { getVideoChannelActivityPubUrl } from '../url' import { videoChannelActivityObjectToDBAttributes } from './misc' async function processCreateActivity (activity: ActivityCreate) { diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index af5d964d4..0328d1a7d 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts @@ -1,11 +1,11 @@ import { ActivityDelete } from '../../../../shared/models/activitypub/activity' -import { getOrCreateAccount } from '../../../helpers/activitypub' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { database as db } from '../../../initializers' import { AccountInstance } from '../../../models/account/account-interface' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' import { VideoInstance } from '../../../models/video/video-interface' +import { getOrCreateAccount } from '../account' async function processDeleteActivity (activity: ActivityDelete) { const account = await getOrCreateAccount(activity.actor) diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 553639580..41b38828c 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -1,9 +1,10 @@ import { ActivityFollow } from '../../../../shared/models/activitypub/activity' -import { getOrCreateAccount, retryTransactionWrapper } from '../../../helpers' +import { retryTransactionWrapper } from '../../../helpers' import { database as db } from '../../../initializers' import { AccountInstance } from '../../../models/account/account-interface' import { logger } from '../../../helpers/logger' import { sendAccept } from '../send/send-accept' +import { getOrCreateAccount } from '../account' async function processFollowActivity (activity: ActivityFollow) { const activityObject = activity.object diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index a3bfb1baf..4876735b8 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts @@ -1,6 +1,5 @@ import { VideoChannelObject, VideoTorrentObject } from '../../../../shared' import { ActivityUpdate } from '../../../../shared/models/activitypub/activity' -import { getOrCreateAccount } from '../../../helpers/activitypub' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { resetSequelizeInstance } from '../../../helpers/utils' @@ -9,6 +8,7 @@ import { AccountInstance } from '../../../models/account/account-interface' import { VideoInstance } from '../../../models/video/video-interface' import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' import Bluebird = require('bluebird') +import { getOrCreateAccount } from '../account' async function processUpdateActivity (activity: ActivityUpdate) { const account = await getOrCreateAccount(activity.actor) -- cgit v1.2.3