aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-19 11:16:23 +0200
committerChocobozzz <me@florianbigard.com>2018-09-19 11:16:23 +0200
commit4157cdb13748cb6e8ce7081d062a8778554cc5a7 (patch)
tree149ee35079c1f81f1294f88aa0122dd5c4d55b22 /server/lib/activitypub/process
parent96f29c0f6d2e623fb088e88200934c5df8da9924 (diff)
downloadPeerTube-4157cdb13748cb6e8ce7081d062a8778554cc5a7.tar.gz
PeerTube-4157cdb13748cb6e8ce7081d062a8778554cc5a7.tar.zst
PeerTube-4157cdb13748cb6e8ce7081d062a8778554cc5a7.zip
Refractor videos AP functions
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r--server/lib/activitypub/process/process-announce.ts2
-rw-r--r--server/lib/activitypub/process/process-create.ts10
-rw-r--r--server/lib/activitypub/process/process-like.ts2
-rw-r--r--server/lib/activitypub/process/process-undo.ts6
-rw-r--r--server/lib/activitypub/process/process-update.ts4
5 files changed, 12 insertions, 12 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index 814556817..b968389b3 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -25,7 +25,7 @@ export {
25async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { 25async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) {
26 const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id 26 const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
27 27
28 const { video } = await getOrCreateVideoAndAccountAndChannel(objectUri) 28 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: objectUri })
29 29
30 return sequelizeTypescript.transaction(async t => { 30 return sequelizeTypescript.transaction(async t => {
31 // Add share entry 31 // Add share entry
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 32e555acf..99841da14 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -48,7 +48,7 @@ export {
48async function processCreateVideo (activity: ActivityCreate) { 48async function processCreateVideo (activity: ActivityCreate) {
49 const videoToCreateData = activity.object as VideoTorrentObject 49 const videoToCreateData = activity.object as VideoTorrentObject
50 50
51 const { video } = await getOrCreateVideoAndAccountAndChannel(videoToCreateData) 51 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData })
52 52
53 return video 53 return video
54} 54}
@@ -59,7 +59,7 @@ async function processCreateDislike (byActor: ActorModel, activity: ActivityCrea
59 59
60 if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url) 60 if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url)
61 61
62 const { video } = await getOrCreateVideoAndAccountAndChannel(dislike.object) 62 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: dislike.object })
63 63
64 return sequelizeTypescript.transaction(async t => { 64 return sequelizeTypescript.transaction(async t => {
65 const rate = { 65 const rate = {
@@ -86,7 +86,7 @@ async function processCreateDislike (byActor: ActorModel, activity: ActivityCrea
86async function processCreateView (byActor: ActorModel, activity: ActivityCreate) { 86async function processCreateView (byActor: ActorModel, activity: ActivityCreate) {
87 const view = activity.object as ViewObject 87 const view = activity.object as ViewObject
88 88
89 const { video } = await getOrCreateVideoAndAccountAndChannel(view.object) 89 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: view.object })
90 90
91 const actor = await ActorModel.loadByUrl(view.actor) 91 const actor = await ActorModel.loadByUrl(view.actor)
92 if (!actor) throw new Error('Unknown actor ' + view.actor) 92 if (!actor) throw new Error('Unknown actor ' + view.actor)
@@ -103,7 +103,7 @@ async function processCreateView (byActor: ActorModel, activity: ActivityCreate)
103async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) { 103async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) {
104 const cacheFile = activity.object as CacheFileObject 104 const cacheFile = activity.object as CacheFileObject
105 105
106 const { video } = await getOrCreateVideoAndAccountAndChannel(cacheFile.object) 106 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFile.object })
107 107
108 await createCacheFile(cacheFile, video, byActor) 108 await createCacheFile(cacheFile, video, byActor)
109 109
@@ -120,7 +120,7 @@ async function processCreateVideoAbuse (actor: ActorModel, videoAbuseToCreateDat
120 const account = actor.Account 120 const account = actor.Account
121 if (!account) throw new Error('Cannot create dislike with the non account actor ' + actor.url) 121 if (!account) throw new Error('Cannot create dislike with the non account actor ' + actor.url)
122 122
123 const { video } = await getOrCreateVideoAndAccountAndChannel(videoAbuseToCreateData.object) 123 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoAbuseToCreateData.object })
124 124
125 return sequelizeTypescript.transaction(async t => { 125 return sequelizeTypescript.transaction(async t => {
126 const videoAbuseData = { 126 const videoAbuseData = {
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index 9e1664fd8..631a9dde7 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -27,7 +27,7 @@ async function processLikeVideo (byActor: ActorModel, activity: ActivityLike) {
27 const byAccount = byActor.Account 27 const byAccount = byActor.Account
28 if (!byAccount) throw new Error('Cannot create like with the non account actor ' + byActor.url) 28 if (!byAccount) throw new Error('Cannot create like with the non account actor ' + byActor.url)
29 29
30 const { video } = await getOrCreateVideoAndAccountAndChannel(videoUrl) 30 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoUrl })
31 31
32 return sequelizeTypescript.transaction(async t => { 32 return sequelizeTypescript.transaction(async t => {
33 const rate = { 33 const rate = {
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index 0eb5fa392..b78de6697 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -54,7 +54,7 @@ export {
54async function processUndoLike (actorUrl: string, activity: ActivityUndo) { 54async function processUndoLike (actorUrl: string, activity: ActivityUndo) {
55 const likeActivity = activity.object as ActivityLike 55 const likeActivity = activity.object as ActivityLike
56 56
57 const { video } = await getOrCreateVideoAndAccountAndChannel(likeActivity.object) 57 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: likeActivity.object })
58 58
59 return sequelizeTypescript.transaction(async t => { 59 return sequelizeTypescript.transaction(async t => {
60 const byAccount = await AccountModel.loadByUrl(actorUrl, t) 60 const byAccount = await AccountModel.loadByUrl(actorUrl, t)
@@ -78,7 +78,7 @@ async function processUndoLike (actorUrl: string, activity: ActivityUndo) {
78async function processUndoDislike (actorUrl: string, activity: ActivityUndo) { 78async function processUndoDislike (actorUrl: string, activity: ActivityUndo) {
79 const dislike = activity.object.object as DislikeObject 79 const dislike = activity.object.object as DislikeObject
80 80
81 const { video } = await getOrCreateVideoAndAccountAndChannel(dislike.object) 81 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: dislike.object })
82 82
83 return sequelizeTypescript.transaction(async t => { 83 return sequelizeTypescript.transaction(async t => {
84 const byAccount = await AccountModel.loadByUrl(actorUrl, t) 84 const byAccount = await AccountModel.loadByUrl(actorUrl, t)
@@ -102,7 +102,7 @@ async function processUndoDislike (actorUrl: string, activity: ActivityUndo) {
102async function processUndoCacheFile (actorUrl: string, activity: ActivityUndo) { 102async function processUndoCacheFile (actorUrl: string, activity: ActivityUndo) {
103 const cacheFileObject = activity.object.object as CacheFileObject 103 const cacheFileObject = activity.object.object as CacheFileObject
104 104
105 const { video } = await getOrCreateVideoAndAccountAndChannel(cacheFileObject.object) 105 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFileObject.object })
106 106
107 return sequelizeTypescript.transaction(async t => { 107 return sequelizeTypescript.transaction(async t => {
108 const byActor = await ActorModel.loadByUrl(actorUrl) 108 const byActor = await ActorModel.loadByUrl(actorUrl)
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index d3af1a181..935da5a54 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -48,7 +48,7 @@ async function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate)
48 return undefined 48 return undefined
49 } 49 }
50 50
51 const { video } = await getOrCreateVideoAndAccountAndChannel(videoObject.id) 51 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id })
52 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject) 52 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
53 53
54 return updateVideoFromAP(video, videoObject, actor.Account, channelActor.VideoChannel, activity.to) 54 return updateVideoFromAP(video, videoObject, actor.Account, channelActor.VideoChannel, activity.to)
@@ -64,7 +64,7 @@ async function processUpdateCacheFile (byActor: ActorModel, activity: ActivityUp
64 64
65 const redundancyModel = await VideoRedundancyModel.loadByUrl(cacheFileObject.id) 65 const redundancyModel = await VideoRedundancyModel.loadByUrl(cacheFileObject.id)
66 if (!redundancyModel) { 66 if (!redundancyModel) {
67 const { video } = await getOrCreateVideoAndAccountAndChannel(cacheFileObject.id) 67 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFileObject.id })
68 return createCacheFile(cacheFileObject, video, byActor) 68 return createCacheFile(cacheFileObject, video, byActor)
69 } 69 }
70 70