aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process-create.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-16 15:22:39 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit20494f122186bb1bfd82f4c598c4744acea27b0c (patch)
tree097652a31ecf70491b970b6c8e06b22380ee004f /server/lib/activitypub/process-create.ts
parentefc32059d980c51793e8e9ac0fb6a885a8026f94 (diff)
downloadPeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.gz
PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.zst
PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.zip
Server shares user videos
Diffstat (limited to 'server/lib/activitypub/process-create.ts')
-rw-r--r--server/lib/activitypub/process-create.ts16
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'
4import { getActivityPubUrl, getOrCreateAccount } from '../../helpers/activitypub' 4import { getActivityPubUrl, getOrCreateAccount } from '../../helpers/activitypub'
5import { database as db } from '../../initializers' 5import { database as db } from '../../initializers'
6import { AccountInstance } from '../../models/account/account-interface' 6import { AccountInstance } from '../../models/account/account-interface'
7import { videoChannelActivityObjectToDBAttributes } from './misc'
7 8
8async function processCreateActivity (activity: ActivityCreate) { 9async 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
40async function addRemoteVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { 41function 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
76async function addRemoteVideoAbuse (account: AccountInstance, videoAbuseToCreateData: VideoAbuseObject) { 68function 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 => {