diff options
Diffstat (limited to 'server/lib/activitypub/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process-create.ts | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/server/lib/activitypub/process-create.ts b/server/lib/activitypub/process-create.ts index 4e4c9f703..c4706a66b 100644 --- a/server/lib/activitypub/process-create.ts +++ b/server/lib/activitypub/process-create.ts | |||
@@ -4,6 +4,7 @@ import { logger, retryTransactionWrapper } from '../../helpers' | |||
4 | import { getActivityPubUrl, getOrCreateAccount } from '../../helpers/activitypub' | 4 | import { getActivityPubUrl, getOrCreateAccount } from '../../helpers/activitypub' |
5 | import { database as db } from '../../initializers' | 5 | import { database as db } from '../../initializers' |
6 | import { AccountInstance } from '../../models/account/account-interface' | 6 | import { AccountInstance } from '../../models/account/account-interface' |
7 | import { videoChannelActivityObjectToDBAttributes } from './misc' | ||
7 | 8 | ||
8 | async function processCreateActivity (activity: ActivityCreate) { | 9 | async function processCreateActivity (activity: ActivityCreate) { |
9 | const activityObject = activity.object | 10 | const activityObject = activity.object |
@@ -37,23 +38,14 @@ function processCreateVideoChannel (account: AccountInstance, videoChannelToCrea | |||
37 | return retryTransactionWrapper(addRemoteVideoChannel, options) | 38 | return retryTransactionWrapper(addRemoteVideoChannel, options) |
38 | } | 39 | } |
39 | 40 | ||
40 | async function addRemoteVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { | 41 | function addRemoteVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { |
41 | logger.debug('Adding remote video channel "%s".', videoChannelToCreateData.uuid) | 42 | logger.debug('Adding remote video channel "%s".', videoChannelToCreateData.uuid) |
42 | 43 | ||
43 | return db.sequelize.transaction(async t => { | 44 | return db.sequelize.transaction(async t => { |
44 | let videoChannel = await db.VideoChannel.loadByUUIDOrUrl(videoChannelToCreateData.uuid, videoChannelToCreateData.id, t) | 45 | let videoChannel = await db.VideoChannel.loadByUUIDOrUrl(videoChannelToCreateData.uuid, videoChannelToCreateData.id, t) |
45 | if (videoChannel) throw new Error('Video channel with this URL/UUID already exists.') | 46 | if (videoChannel) throw new Error('Video channel with this URL/UUID already exists.') |
46 | 47 | ||
47 | const videoChannelData = { | 48 | const videoChannelData = videoChannelActivityObjectToDBAttributes(videoChannelToCreateData, account) |
48 | name: videoChannelToCreateData.name, | ||
49 | description: videoChannelToCreateData.content, | ||
50 | uuid: videoChannelToCreateData.uuid, | ||
51 | createdAt: new Date(videoChannelToCreateData.published), | ||
52 | updatedAt: new Date(videoChannelToCreateData.updated), | ||
53 | remote: true, | ||
54 | accountId: account.id | ||
55 | } | ||
56 | |||
57 | videoChannel = db.VideoChannel.build(videoChannelData) | 49 | videoChannel = db.VideoChannel.build(videoChannelData) |
58 | videoChannel.url = getActivityPubUrl('videoChannel', videoChannel.uuid) | 50 | videoChannel.url = getActivityPubUrl('videoChannel', videoChannel.uuid) |
59 | 51 | ||
@@ -73,7 +65,7 @@ function processCreateVideoAbuse (account: AccountInstance, videoAbuseToCreateDa | |||
73 | return retryTransactionWrapper(addRemoteVideoAbuse, options) | 65 | return retryTransactionWrapper(addRemoteVideoAbuse, options) |
74 | } | 66 | } |
75 | 67 | ||
76 | async function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData: VideoAbuseObject) { | 68 | function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData: VideoAbuseObject) { |
77 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) | 69 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) |
78 | 70 | ||
79 | return db.sequelize.transaction(async t => { | 71 | return db.sequelize.transaction(async t => { |