aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-14 17:38:41 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commit50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch)
treef1732b27edcd05c7877a8358b8312f1e38c287ed /server/lib/activitypub/videos.ts
parentfadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff)
downloadPeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz
PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst
PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip
Begin moving video channel to actor
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts28
1 files changed, 16 insertions, 12 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 14c07fec0..fab43757a 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -19,7 +19,7 @@ import {
19 19
20function fetchRemoteVideoPreview (video: VideoModel) { 20function fetchRemoteVideoPreview (video: VideoModel) {
21 // FIXME: use url 21 // FIXME: use url
22 const host = video.VideoChannel.Account.Server.host 22 const host = video.VideoChannel.Account.Actor.Server.host
23 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName()) 23 const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName())
24 24
25 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path) 25 return request.get(REMOTE_SCHEME.HTTP + '://' + host + path)
@@ -27,7 +27,7 @@ function fetchRemoteVideoPreview (video: VideoModel) {
27 27
28async function fetchRemoteVideoDescription (video: VideoModel) { 28async function fetchRemoteVideoDescription (video: VideoModel) {
29 // FIXME: use url 29 // FIXME: use url
30 const host = video.VideoChannel.Account.Server.host 30 const host = video.VideoChannel.Account.Actor.Server.host
31 const path = video.getDescriptionPath() 31 const path = video.getDescriptionPath()
32 const options = { 32 const options = {
33 uri: REMOTE_SCHEME.HTTP + '://' + host + path, 33 uri: REMOTE_SCHEME.HTTP + '://' + host + path,
@@ -50,43 +50,47 @@ function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject)
50} 50}
51 51
52async function sendVideoRateChangeToFollowers ( 52async function sendVideoRateChangeToFollowers (
53 account: AccountModel, 53 account: AccountModel,
54 video: VideoModel, 54 video: VideoModel,
55 likes: number, 55 likes: number,
56 dislikes: number, 56 dislikes: number,
57 t: Transaction 57 t: Transaction
58) { 58) {
59 const actor = account.Actor
60
59 // Keep the order: first we undo and then we create 61 // Keep the order: first we undo and then we create
60 62
61 // Undo Like 63 // Undo Like
62 if (likes < 0) await sendUndoLikeToVideoFollowers(account, video, t) 64 if (likes < 0) await sendUndoLikeToVideoFollowers(actor, video, t)
63 // Undo Dislike 65 // Undo Dislike
64 if (dislikes < 0) await sendUndoDislikeToVideoFollowers(account, video, t) 66 if (dislikes < 0) await sendUndoDislikeToVideoFollowers(actor, video, t)
65 67
66 // Like 68 // Like
67 if (likes > 0) await sendLikeToVideoFollowers(account, video, t) 69 if (likes > 0) await sendLikeToVideoFollowers(actor, video, t)
68 // Dislike 70 // Dislike
69 if (dislikes > 0) await sendCreateDislikeToVideoFollowers(account, video, t) 71 if (dislikes > 0) await sendCreateDislikeToVideoFollowers(actor, video, t)
70} 72}
71 73
72async function sendVideoRateChangeToOrigin ( 74async function sendVideoRateChangeToOrigin (
73 account: AccountModel, 75 account: AccountModel,
74 video: VideoModel, 76 video: VideoModel,
75 likes: number, 77 likes: number,
76 dislikes: number, 78 dislikes: number,
77 t: Transaction 79 t: Transaction
78) { 80) {
81 const actor = account.Actor
82
79 // Keep the order: first we undo and then we create 83 // Keep the order: first we undo and then we create
80 84
81 // Undo Like 85 // Undo Like
82 if (likes < 0) await sendUndoLikeToOrigin(account, video, t) 86 if (likes < 0) await sendUndoLikeToOrigin(actor, video, t)
83 // Undo Dislike 87 // Undo Dislike
84 if (dislikes < 0) await sendUndoDislikeToOrigin(account, video, t) 88 if (dislikes < 0) await sendUndoDislikeToOrigin(actor, video, t)
85 89
86 // Like 90 // Like
87 if (likes > 0) await sendLikeToOrigin(account, video, t) 91 if (likes > 0) await sendLikeToOrigin(actor, video, t)
88 // Dislike 92 // Dislike
89 if (dislikes > 0) await sendCreateDislikeToOrigin(account, video, t) 93 if (dislikes > 0) await sendCreateDislikeToOrigin(actor, video, t)
90} 94}
91 95
92export { 96export {