aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
commitda854ddd502cd70685ef779c673b9e63757b8aa0 (patch)
tree21501d170cceaa044a5f23449cbd2eb47fd6415d /server/lib
parentf40bbe3146553ef45515ee6b6d93ce6028f045ca (diff)
downloadPeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.gz
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.zst
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.zip
Propagate old comment on new follow
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/actor.ts28
-rw-r--r--server/lib/activitypub/process/misc.ts79
-rw-r--r--server/lib/activitypub/process/process-announce.ts3
-rw-r--r--server/lib/activitypub/process/process-create.ts13
-rw-r--r--server/lib/activitypub/process/process-delete.ts3
-rw-r--r--server/lib/activitypub/process/process-follow.ts3
-rw-r--r--server/lib/activitypub/process/process-like.ts2
-rw-r--r--server/lib/activitypub/process/process-undo.ts3
-rw-r--r--server/lib/activitypub/process/process-update.ts4
-rw-r--r--server/lib/activitypub/process/process.ts2
-rw-r--r--server/lib/activitypub/send/misc.ts2
-rw-r--r--server/lib/activitypub/send/send-create.ts2
-rw-r--r--server/lib/activitypub/share.ts2
-rw-r--r--server/lib/activitypub/url.ts2
-rw-r--r--server/lib/activitypub/videos.ts12
-rw-r--r--server/lib/cache/videos-preview-cache.ts3
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts3
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts6
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts4
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts3
-rw-r--r--server/lib/jobs/job-scheduler.ts2
-rw-r--r--server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts3
-rw-r--r--server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts2
-rw-r--r--server/lib/oauth-model.ts2
24 files changed, 133 insertions, 55 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index ff0a291e8..e590dc72d 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -3,9 +3,12 @@ import { Transaction } from 'sequelize'
3import * as url from 'url' 3import * as url from 'url'
4import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' 4import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub'
5import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' 5import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
6import { createPrivateAndPublicKeys, doRequest, logger, retryTransactionWrapper } from '../../helpers' 6import { isRemoteActorValid } from '../../helpers/custom-validators/activitypub/actor'
7import { isRemoteActorValid } from '../../helpers/custom-validators/activitypub' 7import { retryTransactionWrapper } from '../../helpers/database-utils'
8import { ACTIVITY_PUB, CONFIG, sequelizeTypescript } from '../../initializers' 8import { logger } from '../../helpers/logger'
9import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
10import { doRequest } from '../../helpers/requests'
11import { CONFIG, sequelizeTypescript } from '../../initializers'
9import { AccountModel } from '../../models/account/account' 12import { AccountModel } from '../../models/account/account'
10import { ActorModel } from '../../models/activitypub/actor' 13import { ActorModel } from '../../models/activitypub/actor'
11import { ServerModel } from '../../models/server/server' 14import { ServerModel } from '../../models/server/server'
@@ -115,22 +118,15 @@ async function fetchRemoteActor (actorUrl: string): Promise<FetchRemoteActorResu
115 const options = { 118 const options = {
116 uri: actorUrl, 119 uri: actorUrl,
117 method: 'GET', 120 method: 'GET',
118 headers: { 121 json: true,
119 'Accept': ACTIVITY_PUB.ACCEPT_HEADER 122 activityPub: true
120 }
121 } 123 }
122 124
123 logger.info('Fetching remote actor %s.', actorUrl) 125 logger.info('Fetching remote actor %s.', actorUrl)
124 126
125 let requestResult 127 const requestResult = await doRequest(options)
126 try { 128 const actorJSON: ActivityPubActor = requestResult.body
127 requestResult = await doRequest(options)
128 } catch (err) {
129 logger.warn('Cannot fetch remote actor %s.', actorUrl, err)
130 return undefined
131 }
132 129
133 const actorJSON: ActivityPubActor = JSON.parse(requestResult.body)
134 if (isRemoteActorValid(actorJSON) === false) { 130 if (isRemoteActorValid(actorJSON) === false) {
135 logger.debug('Remote actor JSON is not valid.', { actorJSON: actorJSON }) 131 logger.debug('Remote actor JSON is not valid.', { actorJSON: actorJSON })
136 return undefined 132 return undefined
@@ -195,7 +191,9 @@ export {
195async function fetchActorTotalItems (url: string) { 191async function fetchActorTotalItems (url: string) {
196 const options = { 192 const options = {
197 uri: url, 193 uri: url,
198 method: 'GET' 194 method: 'GET',
195 json: true,
196 activityPub: true
199 } 197 }
200 198
201 let requestResult 199 let requestResult
diff --git a/server/lib/activitypub/process/misc.ts b/server/lib/activitypub/process/misc.ts
index a9c6f913c..f65395c99 100644
--- a/server/lib/activitypub/process/misc.ts
+++ b/server/lib/activitypub/process/misc.ts
@@ -1,11 +1,15 @@
1import * as magnetUtil from 'magnet-uri' 1import * as magnetUtil from 'magnet-uri'
2import { VideoTorrentObject } from '../../../../shared' 2import { VideoTorrentObject } from '../../../../shared'
3import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object'
3import { VideoPrivacy } from '../../../../shared/models/videos' 4import { VideoPrivacy } from '../../../../shared/models/videos'
4import { doRequest } from '../../../helpers'
5import { isVideoFileInfoHashValid } from '../../../helpers/custom-validators/videos' 5import { isVideoFileInfoHashValid } from '../../../helpers/custom-validators/videos'
6import { logger } from '../../../helpers/logger'
7import { doRequest } from '../../../helpers/requests'
6import { ACTIVITY_PUB, VIDEO_MIMETYPE_EXT } from '../../../initializers' 8import { ACTIVITY_PUB, VIDEO_MIMETYPE_EXT } from '../../../initializers'
9import { ActorModel } from '../../../models/activitypub/actor'
7import { VideoModel } from '../../../models/video/video' 10import { VideoModel } from '../../../models/video/video'
8import { VideoChannelModel } from '../../../models/video/video-channel' 11import { VideoChannelModel } from '../../../models/video/video-channel'
12import { VideoCommentModel } from '../../../models/video/video-comment'
9import { VideoShareModel } from '../../../models/video/video-share' 13import { VideoShareModel } from '../../../models/video/video-share'
10import { getOrCreateActorAndServerAndModel } from '../actor' 14import { getOrCreateActorAndServerAndModel } from '../actor'
11 15
@@ -97,14 +101,43 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
97 return attributes 101 return attributes
98} 102}
99 103
100async function addVideoShares (instance: VideoModel, shares: string[]) { 104async function videoCommentActivityObjectToDBAttributes (video: VideoModel, actor: ActorModel, comment: VideoCommentObject) {
101 for (const share of shares) { 105 let originCommentId: number = null
106 let inReplyToCommentId: number = null
107
108 // If this is not a reply to the video (thread), create or get the parent comment
109 if (video.url !== comment.inReplyTo) {
110 const [ parent ] = await addVideoComment(video, comment.inReplyTo)
111 if (!parent) {
112 logger.warn('Cannot fetch or get parent comment %s of comment %s.', comment.inReplyTo, comment.id)
113 return undefined
114 }
115
116 originCommentId = parent.originCommentId || parent.id
117 inReplyToCommentId = parent.id
118 }
119
120 return {
121 url: comment.url,
122 text: comment.content,
123 videoId: video.id,
124 accountId: actor.Account.id,
125 inReplyToCommentId,
126 originCommentId,
127 createdAt: new Date(comment.published),
128 updatedAt: new Date(comment.updated)
129 }
130}
131
132async function addVideoShares (instance: VideoModel, shareUrls: string[]) {
133 for (const shareUrl of shareUrls) {
102 // Fetch url 134 // Fetch url
103 const json = await doRequest({ 135 const { body } = await doRequest({
104 uri: share, 136 uri: shareUrl,
105 json: true 137 json: true,
138 activityPub: true
106 }) 139 })
107 const actorUrl = json['actor'] 140 const actorUrl = body.actor
108 if (!actorUrl) continue 141 if (!actorUrl) continue
109 142
110 const actor = await getOrCreateActorAndServerAndModel(actorUrl) 143 const actor = await getOrCreateActorAndServerAndModel(actorUrl)
@@ -121,10 +154,40 @@ async function addVideoShares (instance: VideoModel, shares: string[]) {
121 } 154 }
122} 155}
123 156
157async function addVideoComments (instance: VideoModel, commentUrls: string[]) {
158 for (const commentUrl of commentUrls) {
159 await addVideoComment(instance, commentUrl)
160 }
161}
162
163async function addVideoComment (instance: VideoModel, commentUrl: string) {
164 // Fetch url
165 const { body } = await doRequest({
166 uri: commentUrl,
167 json: true,
168 activityPub: true
169 })
170
171 const actorUrl = body.attributedTo
172 if (!actorUrl) return []
173
174 const actor = await getOrCreateActorAndServerAndModel(actorUrl)
175 const entry = await videoCommentActivityObjectToDBAttributes(instance, actor, body)
176 if (!entry) return []
177
178 return VideoCommentModel.findOrCreate({
179 where: {
180 url: body.id
181 },
182 defaults: entry
183 })
184}
185
124// --------------------------------------------------------------------------- 186// ---------------------------------------------------------------------------
125 187
126export { 188export {
127 videoFileActivityUrlToDBAttributes, 189 videoFileActivityUrlToDBAttributes,
128 videoActivityObjectToDBAttributes, 190 videoActivityObjectToDBAttributes,
129 addVideoShares 191 addVideoShares,
192 addVideoComments
130} 193}
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index 55f8a62d2..9adb40e01 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -1,5 +1,6 @@
1import { ActivityAnnounce } from '../../../../shared/models/activitypub' 1import { ActivityAnnounce } from '../../../../shared/models/activitypub'
2import { logger, retryTransactionWrapper } from '../../../helpers' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger'
3import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers'
4import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
5import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 628942a58..ffd20fe74 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -3,7 +3,8 @@ import { ActivityCreate, VideoTorrentObject } from '../../../../shared'
3import { DislikeObject, VideoAbuseObject, ViewObject } from '../../../../shared/models/activitypub/objects' 3import { DislikeObject, VideoAbuseObject, ViewObject } from '../../../../shared/models/activitypub/objects'
4import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object' 4import { VideoCommentObject } from '../../../../shared/models/activitypub/objects/video-comment-object'
5import { VideoRateType } from '../../../../shared/models/videos' 5import { VideoRateType } from '../../../../shared/models/videos'
6import { logger, retryTransactionWrapper } from '../../../helpers' 6import { retryTransactionWrapper } from '../../../helpers/database-utils'
7import { logger } from '../../../helpers/logger'
7import { sequelizeTypescript } from '../../../initializers' 8import { sequelizeTypescript } from '../../../initializers'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 9import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { ActorModel } from '../../../models/activitypub/actor' 10import { ActorModel } from '../../../models/activitypub/actor'
@@ -15,7 +16,7 @@ import { VideoFileModel } from '../../../models/video/video-file'
15import { getOrCreateActorAndServerAndModel } from '../actor' 16import { getOrCreateActorAndServerAndModel } from '../actor'
16import { forwardActivity } from '../send/misc' 17import { forwardActivity } from '../send/misc'
17import { generateThumbnailFromUrl } from '../videos' 18import { generateThumbnailFromUrl } from '../videos'
18import { addVideoShares, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' 19import { addVideoComments, addVideoShares, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc'
19 20
20async function processCreateActivity (activity: ActivityCreate) { 21async function processCreateActivity (activity: ActivityCreate) {
21 const activityObject = activity.object 22 const activityObject = activity.object
@@ -66,17 +67,25 @@ async function processCreateVideo (
66 67
67 // Process outside the transaction because we could fetch remote data 68 // Process outside the transaction because we could fetch remote data
68 if (videoToCreateData.likes && Array.isArray(videoToCreateData.likes.orderedItems)) { 69 if (videoToCreateData.likes && Array.isArray(videoToCreateData.likes.orderedItems)) {
70 logger.info('Adding likes of video %s.', video.uuid)
69 await createRates(videoToCreateData.likes.orderedItems, video, 'like') 71 await createRates(videoToCreateData.likes.orderedItems, video, 'like')
70 } 72 }
71 73
72 if (videoToCreateData.dislikes && Array.isArray(videoToCreateData.dislikes.orderedItems)) { 74 if (videoToCreateData.dislikes && Array.isArray(videoToCreateData.dislikes.orderedItems)) {
75 logger.info('Adding dislikes of video %s.', video.uuid)
73 await createRates(videoToCreateData.dislikes.orderedItems, video, 'dislike') 76 await createRates(videoToCreateData.dislikes.orderedItems, video, 'dislike')
74 } 77 }
75 78
76 if (videoToCreateData.shares && Array.isArray(videoToCreateData.shares.orderedItems)) { 79 if (videoToCreateData.shares && Array.isArray(videoToCreateData.shares.orderedItems)) {
80 logger.info('Adding shares of video %s.', video.uuid)
77 await addVideoShares(video, videoToCreateData.shares.orderedItems) 81 await addVideoShares(video, videoToCreateData.shares.orderedItems)
78 } 82 }
79 83
84 if (videoToCreateData.comments && Array.isArray(videoToCreateData.comments.orderedItems)) {
85 logger.info('Adding comments of video %s.', video.uuid)
86 await addVideoComments(video, videoToCreateData.comments.orderedItems)
87 }
88
80 return video 89 return video
81} 90}
82 91
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts
index 65a4e5bcc..523a31822 100644
--- a/server/lib/activitypub/process/process-delete.ts
+++ b/server/lib/activitypub/process/process-delete.ts
@@ -1,5 +1,6 @@
1import { ActivityDelete } from '../../../../shared/models/activitypub' 1import { ActivityDelete } from '../../../../shared/models/activitypub'
2import { logger, retryTransactionWrapper } from '../../../helpers' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger'
3import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers'
4import { AccountModel } from '../../../models/account/account' 5import { AccountModel } from '../../../models/account/account'
5import { ActorModel } from '../../../models/activitypub/actor' 6import { ActorModel } from '../../../models/activitypub/actor'
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index e78005dd0..5085c5da9 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -1,5 +1,6 @@
1import { ActivityFollow } from '../../../../shared/models/activitypub' 1import { ActivityFollow } from '../../../../shared/models/activitypub'
2import { logger, retryTransactionWrapper } from '../../../helpers' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { logger } from '../../../helpers/logger'
3import { sequelizeTypescript } from '../../../initializers' 4import { sequelizeTypescript } from '../../../initializers'
4import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
5import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index a7fcec21c..77fadabe1 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -1,5 +1,5 @@
1import { ActivityLike } from '../../../../shared/models/activitypub' 1import { ActivityLike } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers' 2import { retryTransactionWrapper } from '../../../helpers/database-utils'
3import { sequelizeTypescript } from '../../../initializers' 3import { sequelizeTypescript } from '../../../initializers'
4import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 4import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index 4a0181137..9cad59233 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -1,6 +1,7 @@
1import { ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub' 1import { ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub'
2import { DislikeObject } from '../../../../shared/models/activitypub/objects' 2import { DislikeObject } from '../../../../shared/models/activitypub/objects'
3import { logger, retryTransactionWrapper } from '../../../helpers' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger'
4import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers'
5import { AccountModel } from '../../../models/account/account' 6import { AccountModel } from '../../../models/account/account'
6import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 7import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 35912ee87..a5ad406cb 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -1,6 +1,8 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { ActivityUpdate } from '../../../../shared/models/activitypub' 2import { ActivityUpdate } from '../../../../shared/models/activitypub'
3import { logger, resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger'
5import { resetSequelizeInstance } from '../../../helpers/utils'
4import { sequelizeTypescript } from '../../../initializers' 6import { sequelizeTypescript } from '../../../initializers'
5import { ActorModel } from '../../../models/activitypub/actor' 7import { ActorModel } from '../../../models/activitypub/actor'
6import { TagModel } from '../../../models/video/tag' 8import { TagModel } from '../../../models/video/tag'
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index dfb60c1bf..62d310f21 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -1,5 +1,5 @@
1import { Activity, ActivityType } from '../../../../shared/models/activitypub' 1import { Activity, ActivityType } from '../../../../shared/models/activitypub'
2import { logger } from '../../../helpers' 2import { logger } from '../../../helpers/logger'
3import { ActorModel } from '../../../models/activitypub/actor' 3import { ActorModel } from '../../../models/activitypub/actor'
4import { processAcceptActivity } from './process-accept' 4import { processAcceptActivity } from './process-accept'
5import { processAnnounceActivity } from './process-announce' 5import { processAnnounceActivity } from './process-announce'
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts
index 2dc8d3d59..05f327b29 100644
--- a/server/lib/activitypub/send/misc.ts
+++ b/server/lib/activitypub/send/misc.ts
@@ -1,6 +1,6 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { Activity, ActivityAudience } from '../../../../shared/models/activitypub' 2import { Activity, ActivityAudience } from '../../../../shared/models/activitypub'
3import { logger } from '../../../helpers' 3import { logger } from '../../../helpers/logger'
4import { ACTIVITY_PUB } from '../../../initializers' 4import { ACTIVITY_PUB } from '../../../initializers'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 6import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts
index ca50460be..2f5cdc8c5 100644
--- a/server/lib/activitypub/send/send-create.ts
+++ b/server/lib/activitypub/send/send-create.ts
@@ -1,7 +1,7 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub' 2import { ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub'
3import { VideoPrivacy } from '../../../../shared/models/videos' 3import { VideoPrivacy } from '../../../../shared/models/videos'
4import { getServerActor } from '../../../helpers' 4import { getServerActor } from '../../../helpers/utils'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
7import { VideoAbuseModel } from '../../../models/video/video-abuse' 7import { VideoAbuseModel } from '../../../models/video/video-abuse'
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index 294a6838d..fd374d03d 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,6 +1,6 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { VideoPrivacy } from '../../../shared/models/videos' 2import { VideoPrivacy } from '../../../shared/models/videos'
3import { getServerActor } from '../../helpers' 3import { getServerActor } from '../../helpers/utils'
4import { VideoModel } from '../../models/video/video' 4import { VideoModel } from '../../models/video/video'
5import { VideoShareModel } from '../../models/video/video-share' 5import { VideoShareModel } from '../../models/video/video-share'
6import { sendVideoAnnounceToFollowers } from './send' 6import { sendVideoAnnounceToFollowers } from './send'
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts
index 729bb8dda..3d5f0523c 100644
--- a/server/lib/activitypub/url.ts
+++ b/server/lib/activitypub/url.ts
@@ -10,7 +10,7 @@ function getVideoActivityPubUrl (video: VideoModel) {
10} 10}
11 11
12function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { 12function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
13 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '#comment-' + videoComment.id 13 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
14} 14}
15 15
16function getVideoChannelActivityPubUrl (videoChannelUUID: string) { 16function getVideoChannelActivityPubUrl (videoChannelUUID: string) {
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 83f3e9933..8bc928b93 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -2,19 +2,13 @@ import { join } from 'path'
2import * as request from 'request' 2import * as request from 'request'
3import { Transaction } from 'sequelize' 3import { Transaction } from 'sequelize'
4import { ActivityIconObject } from '../../../shared/index' 4import { ActivityIconObject } from '../../../shared/index'
5import { doRequest, doRequestAndSaveToFile } from '../../helpers' 5import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
6import { CONFIG, REMOTE_SCHEME, STATIC_PATHS } from '../../initializers' 6import { CONFIG, REMOTE_SCHEME, STATIC_PATHS } from '../../initializers'
7import { AccountModel } from '../../models/account/account' 7import { AccountModel } from '../../models/account/account'
8import { VideoModel } from '../../models/video/video' 8import { VideoModel } from '../../models/video/video'
9import { 9import {
10 sendCreateDislikeToOrigin, 10 sendCreateDislikeToOrigin, sendCreateDislikeToVideoFollowers, sendLikeToOrigin, sendLikeToVideoFollowers, sendUndoDislikeToOrigin,
11 sendCreateDislikeToVideoFollowers, 11 sendUndoDislikeToVideoFollowers, sendUndoLikeToOrigin, sendUndoLikeToVideoFollowers
12 sendLikeToOrigin,
13 sendLikeToVideoFollowers,
14 sendUndoDislikeToOrigin,
15 sendUndoDislikeToVideoFollowers,
16 sendUndoLikeToOrigin,
17 sendUndoLikeToVideoFollowers
18} from './send' 12} from './send'
19 13
20function fetchRemoteVideoPreview (video: VideoModel, reject: Function) { 14function fetchRemoteVideoPreview (video: VideoModel, reject: Function) {
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index 930298dbe..d09d55e11 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -1,7 +1,8 @@
1import * as asyncLRU from 'async-lru' 1import * as asyncLRU from 'async-lru'
2import { createWriteStream } from 'fs' 2import { createWriteStream } from 'fs'
3import { join } from 'path' 3import { join } from 'path'
4import { logger, unlinkPromise } from '../../helpers' 4import { unlinkPromise } from '../../helpers/core-utils'
5import { logger } from '../../helpers/logger'
5import { CACHE, CONFIG } from '../../initializers' 6import { CACHE, CONFIG } from '../../initializers'
6import { VideoModel } from '../../models/video/video' 7import { VideoModel } from '../../models/video/video'
7import { fetchRemoteVideoPreview } from '../activitypub' 8import { fetchRemoteVideoPreview } from '../activitypub'
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts
index 3c4d5556f..c20a48a4e 100644
--- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts
+++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-broadcast-handler.ts
@@ -1,4 +1,5 @@
1import { doRequest, logger } from '../../../helpers' 1import { logger } from '../../../helpers/logger'
2import { doRequest } from '../../../helpers/requests'
2import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler' 3import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler'
3 4
4async function process (payload: ActivityPubHttpPayload, jobId: number) { 5async function process (payload: ActivityPubHttpPayload, jobId: number) {
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts
index 638150202..a7b5aabd0 100644
--- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts
+++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-fetcher-handler.ts
@@ -1,4 +1,5 @@
1import { doRequest, logger } from '../../../helpers' 1import { logger } from '../../../helpers/logger'
2import { doRequest } from '../../../helpers/requests'
2import { ACTIVITY_PUB } from '../../../initializers' 3import { ACTIVITY_PUB } from '../../../initializers'
3import { processActivities } from '../../activitypub/process' 4import { processActivities } from '../../activitypub/process'
4import { ActivityPubHttpPayload } from './activitypub-http-job-scheduler' 5import { ActivityPubHttpPayload } from './activitypub-http-job-scheduler'
@@ -9,7 +10,8 @@ async function process (payload: ActivityPubHttpPayload, jobId: number) {
9 const options = { 10 const options = {
10 method: 'GET', 11 method: 'GET',
11 uri: '', 12 uri: '',
12 json: true 13 json: true,
14 activityPub: true
13 } 15 }
14 16
15 for (const uri of payload.uris) { 17 for (const uri of payload.uris) {
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts
index 88885cf97..d576cd42e 100644
--- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts
+++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts
@@ -1,5 +1,7 @@
1import { JobCategory } from '../../../../shared' 1import { JobCategory } from '../../../../shared'
2import { buildSignedActivity, getServerActor, logger } from '../../../helpers' 2import { buildSignedActivity } from '../../../helpers/activitypub'
3import { logger } from '../../../helpers/logger'
4import { getServerActor } from '../../../helpers/utils'
3import { ACTIVITY_PUB } from '../../../initializers' 5import { ACTIVITY_PUB } from '../../../initializers'
4import { ActorModel } from '../../../models/activitypub/actor' 6import { ActorModel } from '../../../models/activitypub/actor'
5import { JobHandler, JobScheduler } from '../job-scheduler' 7import { JobHandler, JobScheduler } from '../job-scheduler'
diff --git a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts
index 7a5caa679..175ec6642 100644
--- a/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts
+++ b/server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts
@@ -1,4 +1,5 @@
1import { doRequest, logger } from '../../../helpers' 1import { logger } from '../../../helpers/logger'
2import { doRequest } from '../../../helpers/requests'
2import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler' 3import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler'
3 4
4async function process (payload: ActivityPubHttpPayload, jobId: number) { 5async function process (payload: ActivityPubHttpPayload, jobId: number) {
diff --git a/server/lib/jobs/job-scheduler.ts b/server/lib/jobs/job-scheduler.ts
index 88fe8a4a3..9d55880e6 100644
--- a/server/lib/jobs/job-scheduler.ts
+++ b/server/lib/jobs/job-scheduler.ts
@@ -1,7 +1,7 @@
1import { AsyncQueue, forever, queue } from 'async' 1import { AsyncQueue, forever, queue } from 'async'
2import * as Sequelize from 'sequelize' 2import * as Sequelize from 'sequelize'
3import { JobCategory } from '../../../shared' 3import { JobCategory } from '../../../shared'
4import { logger } from '../../helpers' 4import { logger } from '../../helpers/logger'
5import { JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers' 5import { JOB_STATES, JOBS_FETCH_LIMIT_PER_CYCLE, JOBS_FETCHING_INTERVAL } from '../../initializers'
6import { JobModel } from '../../models/job/job' 6import { JobModel } from '../../models/job/job'
7 7
diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
index d905882be..23677e8d5 100644
--- a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
+++ b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts
@@ -1,6 +1,7 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { VideoPrivacy } from '../../../../shared/models/videos' 2import { VideoPrivacy } from '../../../../shared/models/videos'
3import { computeResolutionsToTranscode, logger } from '../../../helpers' 3import { logger } from '../../../helpers/logger'
4import { computeResolutionsToTranscode } from '../../../helpers/utils'
4import { sequelizeTypescript } from '../../../initializers' 5import { sequelizeTypescript } from '../../../initializers'
5import { VideoModel } from '../../../models/video/video' 6import { VideoModel } from '../../../models/video/video'
6import { shareVideoByServerAndChannel } from '../../activitypub' 7import { shareVideoByServerAndChannel } from '../../activitypub'
diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
index 409123bfe..883d3eba8 100644
--- a/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
+++ b/server/lib/jobs/transcoding-job-scheduler/video-file-transcoder-handler.ts
@@ -1,6 +1,6 @@
1import { VideoResolution } from '../../../../shared' 1import { VideoResolution } from '../../../../shared'
2import { VideoPrivacy } from '../../../../shared/models/videos' 2import { VideoPrivacy } from '../../../../shared/models/videos'
3import { logger } from '../../../helpers' 3import { logger } from '../../../helpers/logger'
4import { VideoModel } from '../../../models/video/video' 4import { VideoModel } from '../../../models/video/video'
5import { sendUpdateVideo } from '../../activitypub/send' 5import { sendUpdateVideo } from '../../activitypub/send'
6 6
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index dce71e83b..b3cc75590 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -1,4 +1,4 @@
1import { logger } from '../helpers' 1import { logger } from '../helpers/logger'
2import { UserModel } from '../models/account/user' 2import { UserModel } from '../models/account/user'
3import { OAuthClientModel } from '../models/oauth/oauth-client' 3import { OAuthClientModel } from '../models/oauth/oauth-client'
4import { OAuthTokenModel } from '../models/oauth/oauth-token' 4import { OAuthTokenModel } from '../models/oauth/oauth-token'