diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-20 10:24:29 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 892211e8493b1f992fce7616cb1e48b7ff87a1dc (patch) | |
tree | 7bb218141a20c14d293d695ad4dad12687e537b2 /server/lib/activitypub/process | |
parent | 54141398354e6e7b94aa3065a705a1251390111c (diff) | |
download | PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.tar.gz PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.tar.zst PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.zip |
Move activitypub functions from helpers/ to lib/
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r-- | server/lib/activitypub/process/process-add.ts | 17 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 2 |
6 files changed, 16 insertions, 13 deletions
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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import { VideoTorrentObject } from '../../../../shared' | 2 | import { VideoTorrentObject } from '../../../../shared' |
3 | import { ActivityAdd } from '../../../../shared/models/activitypub/activity' | 3 | import { ActivityAdd } from '../../../../shared/models/activitypub/activity' |
4 | import { generateThumbnailFromUrl, getOrCreateAccount, logger, retryTransactionWrapper } from '../../../helpers' | 4 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
5 | import { getOrCreateVideoChannel } from '../../../helpers/activitypub' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { database as db } from '../../../initializers' | 6 | import { database as db } from '../../../initializers' |
7 | import { AccountInstance } from '../../../models/account/account-interface' | 7 | import { AccountInstance } from '../../../models/account/account-interface' |
8 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' | 8 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' |
9 | import { getOrCreateAccount } from '../account' | ||
10 | import { getOrCreateVideoChannel } from '../video-channels' | ||
11 | import { generateThumbnailFromUrl } from '../videos' | ||
9 | import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' | 12 | import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' |
10 | 13 | ||
11 | async function processAddActivity (activity: ActivityAdd) { | 14 | async function processAddActivity (activity: ActivityAdd) { |
@@ -41,12 +44,10 @@ function processAddVideo (account: AccountInstance, activity: ActivityAdd, video | |||
41 | return retryTransactionWrapper(addRemoteVideo, options) | 44 | return retryTransactionWrapper(addRemoteVideo, options) |
42 | } | 45 | } |
43 | 46 | ||
44 | function addRemoteVideo ( | 47 | function addRemoteVideo (account: AccountInstance, |
45 | account: AccountInstance, | 48 | activity: ActivityAdd, |
46 | activity: ActivityAdd, | 49 | videoChannel: VideoChannelInstance, |
47 | videoChannel: VideoChannelInstance, | 50 | videoToCreateData: VideoTorrentObject) { |
48 | videoToCreateData: VideoTorrentObject | ||
49 | ) { | ||
50 | logger.debug('Adding remote video %s.', videoToCreateData.url) | 51 | logger.debug('Adding remote video %s.', videoToCreateData.url) |
51 | 52 | ||
52 | return db.sequelize.transaction(async t => { | 53 | 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 @@ | |||
1 | import { ActivityAnnounce } from '../../../../shared/models/activitypub/activity' | 1 | import { ActivityAnnounce } from '../../../../shared/models/activitypub/activity' |
2 | import { getOrCreateAccount } from '../../../helpers/activitypub' | ||
3 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
4 | import { database as db } from '../../../initializers/index' | 3 | import { database as db } from '../../../initializers/index' |
5 | import { VideoInstance } from '../../../models/index' | 4 | import { VideoInstance } from '../../../models/index' |
6 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' | 5 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' |
7 | import { processAddActivity } from './process-add' | 6 | import { processAddActivity } from './process-add' |
8 | import { processCreateActivity } from './process-create' | 7 | import { processCreateActivity } from './process-create' |
8 | import { getOrCreateAccount } from '../account' | ||
9 | 9 | ||
10 | async function processAnnounceActivity (activity: ActivityAnnounce) { | 10 | async function processAnnounceActivity (activity: ActivityAnnounce) { |
11 | const announcedActivity = activity.object | 11 | 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 @@ | |||
1 | import { ActivityCreate, VideoChannelObject } from '../../../../shared' | 1 | import { ActivityCreate, VideoChannelObject } from '../../../../shared' |
2 | import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects/video-abuse-object' | 2 | import { VideoAbuseObject } from '../../../../shared/models/activitypub/objects/video-abuse-object' |
3 | import { logger, retryTransactionWrapper } from '../../../helpers' | 3 | import { logger, retryTransactionWrapper } from '../../../helpers' |
4 | import { getOrCreateAccount, getVideoChannelActivityPubUrl } from '../../../helpers/activitypub' | ||
5 | import { database as db } from '../../../initializers' | 4 | import { database as db } from '../../../initializers' |
6 | import { AccountInstance } from '../../../models/account/account-interface' | 5 | import { AccountInstance } from '../../../models/account/account-interface' |
6 | import { getOrCreateAccount } from '../account' | ||
7 | import { getVideoChannelActivityPubUrl } from '../url' | ||
7 | import { videoChannelActivityObjectToDBAttributes } from './misc' | 8 | import { videoChannelActivityObjectToDBAttributes } from './misc' |
8 | 9 | ||
9 | async function processCreateActivity (activity: ActivityCreate) { | 10 | 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 @@ | |||
1 | import { ActivityDelete } from '../../../../shared/models/activitypub/activity' | 1 | import { ActivityDelete } from '../../../../shared/models/activitypub/activity' |
2 | import { getOrCreateAccount } from '../../../helpers/activitypub' | ||
3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
4 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
5 | import { database as db } from '../../../initializers' | 4 | import { database as db } from '../../../initializers' |
6 | import { AccountInstance } from '../../../models/account/account-interface' | 5 | import { AccountInstance } from '../../../models/account/account-interface' |
7 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' | 6 | import { VideoChannelInstance } from '../../../models/video/video-channel-interface' |
8 | import { VideoInstance } from '../../../models/video/video-interface' | 7 | import { VideoInstance } from '../../../models/video/video-interface' |
8 | import { getOrCreateAccount } from '../account' | ||
9 | 9 | ||
10 | async function processDeleteActivity (activity: ActivityDelete) { | 10 | async function processDeleteActivity (activity: ActivityDelete) { |
11 | const account = await getOrCreateAccount(activity.actor) | 11 | 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 @@ | |||
1 | import { ActivityFollow } from '../../../../shared/models/activitypub/activity' | 1 | import { ActivityFollow } from '../../../../shared/models/activitypub/activity' |
2 | import { getOrCreateAccount, retryTransactionWrapper } from '../../../helpers' | 2 | import { retryTransactionWrapper } from '../../../helpers' |
3 | import { database as db } from '../../../initializers' | 3 | import { database as db } from '../../../initializers' |
4 | import { AccountInstance } from '../../../models/account/account-interface' | 4 | import { AccountInstance } from '../../../models/account/account-interface' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { sendAccept } from '../send/send-accept' | 6 | import { sendAccept } from '../send/send-accept' |
7 | import { getOrCreateAccount } from '../account' | ||
7 | 8 | ||
8 | async function processFollowActivity (activity: ActivityFollow) { | 9 | async function processFollowActivity (activity: ActivityFollow) { |
9 | const activityObject = activity.object | 10 | 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 @@ | |||
1 | import { VideoChannelObject, VideoTorrentObject } from '../../../../shared' | 1 | import { VideoChannelObject, VideoTorrentObject } from '../../../../shared' |
2 | import { ActivityUpdate } from '../../../../shared/models/activitypub/activity' | 2 | import { ActivityUpdate } from '../../../../shared/models/activitypub/activity' |
3 | import { getOrCreateAccount } from '../../../helpers/activitypub' | ||
4 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
5 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
6 | import { resetSequelizeInstance } from '../../../helpers/utils' | 5 | import { resetSequelizeInstance } from '../../../helpers/utils' |
@@ -9,6 +8,7 @@ import { AccountInstance } from '../../../models/account/account-interface' | |||
9 | import { VideoInstance } from '../../../models/video/video-interface' | 8 | import { VideoInstance } from '../../../models/video/video-interface' |
10 | import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' | 9 | import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' |
11 | import Bluebird = require('bluebird') | 10 | import Bluebird = require('bluebird') |
11 | import { getOrCreateAccount } from '../account' | ||
12 | 12 | ||
13 | async function processUpdateActivity (activity: ActivityUpdate) { | 13 | async function processUpdateActivity (activity: ActivityUpdate) { |
14 | const account = await getOrCreateAccount(activity.actor) | 14 | const account = await getOrCreateAccount(activity.actor) |