aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/controllers/activitypub/client.ts9
-rw-r--r--server/controllers/activitypub/outbox.ts3
-rw-r--r--server/lib/activitypub/activity.ts21
-rw-r--r--server/lib/activitypub/actors/get.ts4
-rw-r--r--server/lib/activitypub/actors/shared/url-to-object.ts3
-rw-r--r--server/lib/activitypub/collection.ts62
-rw-r--r--server/lib/activitypub/context.ts (renamed from server/helpers/activitypub.ts)98
-rw-r--r--server/lib/activitypub/playlists/create-update.ts4
-rw-r--r--server/lib/activitypub/playlists/get.ts2
-rw-r--r--server/lib/activitypub/playlists/shared/url-to-object.ts2
-rw-r--r--server/lib/activitypub/process/process-announce.ts10
-rw-r--r--server/lib/activitypub/process/process-flag.ts2
-rw-r--r--server/lib/activitypub/process/process-follow.ts2
-rw-r--r--server/lib/activitypub/process/process-like.ts2
-rw-r--r--server/lib/activitypub/process/process.ts3
-rw-r--r--server/lib/activitypub/share.ts4
-rw-r--r--server/lib/activitypub/url.ts31
-rw-r--r--server/lib/activitypub/video-comments.ts2
-rw-r--r--server/lib/activitypub/videos/get.ts2
-rw-r--r--server/lib/activitypub/videos/shared/abstract-builder.ts2
-rw-r--r--server/lib/activitypub/videos/shared/trackers.ts2
-rw-r--r--server/lib/activitypub/videos/shared/url-to-object.ts2
-rw-r--r--server/lib/job-queue/handlers/activitypub-cleaner.ts2
-rw-r--r--server/lib/job-queue/handlers/utils/activitypub-http-utils.ts2
-rw-r--r--server/middlewares/activitypub.ts2
-rw-r--r--server/models/actor/actor.ts2
-rw-r--r--server/models/video/video-file.ts2
-rw-r--r--server/models/video/video-playlist.ts2
-rw-r--r--server/tests/api/activitypub/helpers.ts2
-rw-r--r--server/tests/api/activitypub/security.ts3
-rw-r--r--server/tests/shared/requests.ts2
31 files changed, 155 insertions, 136 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index fc27ebbe8..99637dbab 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -1,10 +1,11 @@
1import cors from 'cors' 1import cors from 'cors'
2import express from 'express' 2import express from 'express'
3import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
4import { activityPubContextify } from '@server/lib/activitypub/context'
3import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
4import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' 6import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
5import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' 7import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
6import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 8import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
7import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
8import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants' 9import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants'
9import { audiencify, getAudience } from '../../lib/activitypub/audience' 10import { audiencify, getAudience } from '../../lib/activitypub/audience'
10import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send' 11import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
@@ -400,7 +401,7 @@ function videoPlaylistElementController (req: express.Request, res: express.Resp
400 401
401// --------------------------------------------------------------------------- 402// ---------------------------------------------------------------------------
402 403
403async function actorFollowing (req: express.Request, actor: MActorId) { 404function actorFollowing (req: express.Request, actor: MActorId) {
404 const handler = (start: number, count: number) => { 405 const handler = (start: number, count: number) => {
405 return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count) 406 return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count)
406 } 407 }
@@ -408,7 +409,7 @@ async function actorFollowing (req: express.Request, actor: MActorId) {
408 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) 409 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
409} 410}
410 411
411async function actorFollowers (req: express.Request, actor: MActorId) { 412function actorFollowers (req: express.Request, actor: MActorId) {
412 const handler = (start: number, count: number) => { 413 const handler = (start: number, count: number) => {
413 return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count) 414 return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count)
414 } 415 }
@@ -416,7 +417,7 @@ async function actorFollowers (req: express.Request, actor: MActorId) {
416 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) 417 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
417} 418}
418 419
419async function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) { 420function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) {
420 const handler = (start: number, count: number) => { 421 const handler = (start: number, count: number) => {
421 return VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count) 422 return VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count)
422 } 423 }
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts
index cdef8e969..4e7a3afeb 100644
--- a/server/controllers/activitypub/outbox.ts
+++ b/server/controllers/activitypub/outbox.ts
@@ -1,8 +1,9 @@
1import express from 'express' 1import express from 'express'
2import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
3import { activityPubContextify } from '@server/lib/activitypub/context'
2import { MActorLight } from '@server/types/models' 4import { MActorLight } from '@server/types/models'
3import { Activity } from '../../../shared/models/activitypub/activity' 5import { Activity } from '../../../shared/models/activitypub/activity'
4import { VideoPrivacy } from '../../../shared/models/videos' 6import { VideoPrivacy } from '../../../shared/models/videos'
5import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
6import { logger } from '../../helpers/logger' 7import { logger } from '../../helpers/logger'
7import { buildAudience } from '../../lib/activitypub/audience' 8import { buildAudience } from '../../lib/activitypub/audience'
8import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send' 9import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send'
diff --git a/server/lib/activitypub/activity.ts b/server/lib/activitypub/activity.ts
new file mode 100644
index 000000000..215b50b69
--- /dev/null
+++ b/server/lib/activitypub/activity.ts
@@ -0,0 +1,21 @@
1import { signJsonLDObject } from '@server/helpers/peertube-crypto'
2import { MActor } from '@server/types/models'
3import { ContextType } from '@shared/models'
4import { activityPubContextify } from './context'
5
6function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
7 const activity = activityPubContextify(data, contextType)
8
9 return signJsonLDObject(byActor, activity)
10}
11
12function getAPId (object: string | { id: string }) {
13 if (typeof object === 'string') return object
14
15 return object.id
16}
17
18export {
19 buildSignedActivity,
20 getAPId
21}
diff --git a/server/lib/activitypub/actors/get.ts b/server/lib/activitypub/actors/get.ts
index 4200ddb4d..d2b651082 100644
--- a/server/lib/activitypub/actors/get.ts
+++ b/server/lib/activitypub/actors/get.ts
@@ -1,11 +1,11 @@
1
2import { checkUrlsSameHost, getAPId } from '@server/helpers/activitypub'
3import { retryTransactionWrapper } from '@server/helpers/database-utils' 1import { retryTransactionWrapper } from '@server/helpers/database-utils'
4import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
5import { JobQueue } from '@server/lib/job-queue' 3import { JobQueue } from '@server/lib/job-queue'
6import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders' 4import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders'
7import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models' 5import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models'
8import { ActivityPubActor } from '@shared/models' 6import { ActivityPubActor } from '@shared/models'
7import { getAPId } from '../activity'
8import { checkUrlsSameHost } from '../url'
9import { refreshActorIfNeeded } from './refresh' 9import { refreshActorIfNeeded } from './refresh'
10import { APActorCreator, fetchRemoteActor } from './shared' 10import { APActorCreator, fetchRemoteActor } from './shared'
11 11
diff --git a/server/lib/activitypub/actors/shared/url-to-object.ts b/server/lib/activitypub/actors/shared/url-to-object.ts
index f4f16b044..982d52b79 100644
--- a/server/lib/activitypub/actors/shared/url-to-object.ts
+++ b/server/lib/activitypub/actors/shared/url-to-object.ts
@@ -1,9 +1,8 @@
1
2import { checkUrlsSameHost } from '@server/helpers/activitypub'
3import { sanitizeAndCheckActorObject } from '@server/helpers/custom-validators/activitypub/actor' 1import { sanitizeAndCheckActorObject } from '@server/helpers/custom-validators/activitypub/actor'
4import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
5import { doJSONRequest } from '@server/helpers/requests' 3import { doJSONRequest } from '@server/helpers/requests'
6import { ActivityPubActor, ActivityPubOrderedCollection } from '@shared/models' 4import { ActivityPubActor, ActivityPubOrderedCollection } from '@shared/models'
5import { checkUrlsSameHost } from '../../url'
7 6
8async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode: number, actorObject: ActivityPubActor }> { 7async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode: number, actorObject: ActivityPubActor }> {
9 logger.info('Fetching remote actor %s.', actorUrl) 8 logger.info('Fetching remote actor %s.', actorUrl)
diff --git a/server/lib/activitypub/collection.ts b/server/lib/activitypub/collection.ts
new file mode 100644
index 000000000..43a704aa4
--- /dev/null
+++ b/server/lib/activitypub/collection.ts
@@ -0,0 +1,62 @@
1import Bluebird from 'bluebird'
2import validator from 'validator'
3import { pageToStartAndCount } from '@server/helpers/core-utils'
4import { ACTIVITY_PUB } from '@server/initializers/constants'
5import { ResultList } from '@shared/models'
6
7type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>>
8
9async function activityPubCollectionPagination (
10 baseUrl: string,
11 handler: ActivityPubCollectionPaginationHandler,
12 page?: any,
13 size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE
14) {
15 if (!page || !validator.isInt(page)) {
16 // We just display the first page URL, we only need the total items
17 const result = await handler(0, 1)
18
19 return {
20 id: baseUrl,
21 type: 'OrderedCollectionPage',
22 totalItems: result.total,
23 first: result.data.length === 0
24 ? undefined
25 : baseUrl + '?page=1'
26 }
27 }
28
29 const { start, count } = pageToStartAndCount(page, size)
30 const result = await handler(start, count)
31
32 let next: string | undefined
33 let prev: string | undefined
34
35 // Assert page is a number
36 page = parseInt(page, 10)
37
38 // There are more results
39 if (result.total > page * size) {
40 next = baseUrl + '?page=' + (page + 1)
41 }
42
43 if (page > 1) {
44 prev = baseUrl + '?page=' + (page - 1)
45 }
46
47 return {
48 id: baseUrl + '?page=' + page,
49 type: 'OrderedCollectionPage',
50 prev,
51 next,
52 partOf: baseUrl,
53 orderedItems: result.data,
54 totalItems: result.total
55 }
56}
57
58// ---------------------------------------------------------------------------
59
60export {
61 activityPubCollectionPagination
62}
diff --git a/server/helpers/activitypub.ts b/server/lib/activitypub/context.ts
index 9d6d8b2fa..71f08da80 100644
--- a/server/helpers/activitypub.ts
+++ b/server/lib/activitypub/context.ts
@@ -1,12 +1,4 @@
1import Bluebird from 'bluebird' 1import { ContextType } from '@shared/models'
2import { URL } from 'url'
3import validator from 'validator'
4import { ContextType } from '@shared/models/activitypub/context'
5import { ResultList } from '../../shared/models'
6import { ACTIVITY_PUB, REMOTE_SCHEME } from '../initializers/constants'
7import { MActor, MVideoWithHost } from '../types/models'
8import { pageToStartAndCount } from './core-utils'
9import { signJsonLDObject } from './peertube-crypto'
10 2
11function getContextData (type: ContextType) { 3function getContextData (type: ContextType) {
12 const context: any[] = [ 4 const context: any[] = [
@@ -139,91 +131,7 @@ function activityPubContextify <T> (data: T, type: ContextType = 'All') {
139 return Object.assign({}, data, getContextData(type)) 131 return Object.assign({}, data, getContextData(type))
140} 132}
141 133
142type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>>
143async function activityPubCollectionPagination (
144 baseUrl: string,
145 handler: ActivityPubCollectionPaginationHandler,
146 page?: any,
147 size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE
148) {
149 if (!page || !validator.isInt(page)) {
150 // We just display the first page URL, we only need the total items
151 const result = await handler(0, 1)
152
153 return {
154 id: baseUrl,
155 type: 'OrderedCollectionPage',
156 totalItems: result.total,
157 first: result.data.length === 0
158 ? undefined
159 : baseUrl + '?page=1'
160 }
161 }
162
163 const { start, count } = pageToStartAndCount(page, size)
164 const result = await handler(start, count)
165
166 let next: string | undefined
167 let prev: string | undefined
168
169 // Assert page is a number
170 page = parseInt(page, 10)
171
172 // There are more results
173 if (result.total > page * size) {
174 next = baseUrl + '?page=' + (page + 1)
175 }
176
177 if (page > 1) {
178 prev = baseUrl + '?page=' + (page - 1)
179 }
180
181 return {
182 id: baseUrl + '?page=' + page,
183 type: 'OrderedCollectionPage',
184 prev,
185 next,
186 partOf: baseUrl,
187 orderedItems: result.data,
188 totalItems: result.total
189 }
190
191}
192
193function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
194 const activity = activityPubContextify(data, contextType)
195
196 return signJsonLDObject(byActor, activity)
197}
198
199function getAPId (object: string | { id: string }) {
200 if (typeof object === 'string') return object
201
202 return object.id
203}
204
205function checkUrlsSameHost (url1: string, url2: string) {
206 const idHost = new URL(url1).host
207 const actorHost = new URL(url2).host
208
209 return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
210}
211
212function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
213 if (!scheme) scheme = REMOTE_SCHEME.HTTP
214
215 const host = video.VideoChannel.Actor.Server.host
216
217 return scheme + '://' + host + path
218}
219
220// ---------------------------------------------------------------------------
221
222export { 134export {
223 checkUrlsSameHost, 135 getContextData,
224 getAPId, 136 activityPubContextify
225 activityPubContextify,
226 activityPubCollectionPagination,
227 buildSignedActivity,
228 buildRemoteVideoBaseUrl
229} 137}
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index ef572c803..c28700be6 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -1,5 +1,4 @@
1import { map } from 'bluebird' 1import { map } from 'bluebird'
2import { getAPId } from '@server/helpers/activitypub'
3import { isArray } from '@server/helpers/custom-validators/misc' 2import { isArray } from '@server/helpers/custom-validators/misc'
4import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory } from '@server/helpers/logger'
5import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' 4import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
@@ -9,8 +8,9 @@ import { VideoPlaylistModel } from '@server/models/video/video-playlist'
9import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' 8import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
10import { FilteredModelAttributes } from '@server/types' 9import { FilteredModelAttributes } from '@server/types'
11import { MThumbnail, MVideoPlaylist, MVideoPlaylistFull, MVideoPlaylistVideosLength } from '@server/types/models' 10import { MThumbnail, MVideoPlaylist, MVideoPlaylistFull, MVideoPlaylistVideosLength } from '@server/types/models'
12import { AttributesOnly } from '@shared/typescript-utils'
13import { PlaylistObject } from '@shared/models' 11import { PlaylistObject } from '@shared/models'
12import { AttributesOnly } from '@shared/typescript-utils'
13import { getAPId } from '../activity'
14import { getOrCreateAPActor } from '../actors' 14import { getOrCreateAPActor } from '../actors'
15import { crawlCollectionPage } from '../crawl' 15import { crawlCollectionPage } from '../crawl'
16import { getOrCreateAPVideo } from '../videos' 16import { getOrCreateAPVideo } from '../videos'
diff --git a/server/lib/activitypub/playlists/get.ts b/server/lib/activitypub/playlists/get.ts
index be8456b19..bfaf52cc9 100644
--- a/server/lib/activitypub/playlists/get.ts
+++ b/server/lib/activitypub/playlists/get.ts
@@ -1,7 +1,7 @@
1import { getAPId } from '@server/helpers/activitypub'
2import { VideoPlaylistModel } from '@server/models/video/video-playlist' 1import { VideoPlaylistModel } from '@server/models/video/video-playlist'
3import { MVideoPlaylistFullSummary } from '@server/types/models' 2import { MVideoPlaylistFullSummary } from '@server/types/models'
4import { APObject } from '@shared/models' 3import { APObject } from '@shared/models'
4import { getAPId } from '../activity'
5import { createOrUpdateVideoPlaylist } from './create-update' 5import { createOrUpdateVideoPlaylist } from './create-update'
6import { scheduleRefreshIfNeeded } from './refresh' 6import { scheduleRefreshIfNeeded } from './refresh'
7import { fetchRemoteVideoPlaylist } from './shared' 7import { fetchRemoteVideoPlaylist } from './shared'
diff --git a/server/lib/activitypub/playlists/shared/url-to-object.ts b/server/lib/activitypub/playlists/shared/url-to-object.ts
index ec8c01255..f895db587 100644
--- a/server/lib/activitypub/playlists/shared/url-to-object.ts
+++ b/server/lib/activitypub/playlists/shared/url-to-object.ts
@@ -1,9 +1,9 @@
1import { isArray } from 'lodash' 1import { isArray } from 'lodash'
2import { checkUrlsSameHost } from '@server/helpers/activitypub'
3import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '@server/helpers/custom-validators/activitypub/playlist' 2import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '@server/helpers/custom-validators/activitypub/playlist'
4import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory } from '@server/helpers/logger'
5import { doJSONRequest } from '@server/helpers/requests' 4import { doJSONRequest } from '@server/helpers/requests'
6import { PlaylistElementObject, PlaylistObject } from '@shared/models' 5import { PlaylistElementObject, PlaylistObject } from '@shared/models'
6import { checkUrlsSameHost } from '../../url'
7 7
8async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusCode: number, playlistObject: PlaylistObject }> { 8async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusCode: number, playlistObject: PlaylistObject }> {
9 const lTags = loggerTagsFactory('ap', 'video-playlist', playlistUrl) 9 const lTags = loggerTagsFactory('ap', 'video-playlist', playlistUrl)
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index 200f8ce11..9cc87ee27 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -1,14 +1,14 @@
1import { getAPId } from '@server/lib/activitypub/activity'
1import { ActivityAnnounce } from '../../../../shared/models/activitypub' 2import { ActivityAnnounce } from '../../../../shared/models/activitypub'
2import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
4import { logger } from '../../../helpers/logger'
3import { sequelizeTypescript } from '../../../initializers/database' 5import { sequelizeTypescript } from '../../../initializers/database'
4import { VideoShareModel } from '../../../models/video/video-share' 6import { VideoShareModel } from '../../../models/video/video-share'
5import { forwardVideoRelatedActivity } from '../send/shared/send-utils'
6import { getOrCreateAPVideo } from '../videos'
7import { Notifier } from '../../notifier'
8import { logger } from '../../../helpers/logger'
9import { APProcessorOptions } from '../../../types/activitypub-processor.model' 7import { APProcessorOptions } from '../../../types/activitypub-processor.model'
10import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models' 8import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models'
11import { getAPId } from '@server/helpers/activitypub' 9import { Notifier } from '../../notifier'
10import { forwardVideoRelatedActivity } from '../send/shared/send-utils'
11import { getOrCreateAPVideo } from '../videos'
12 12
13async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) { 13async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
14 const { activity, byActor: actorAnnouncer } = options 14 const { activity, byActor: actorAnnouncer } = options
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts
index a15d07a62..10f58ef27 100644
--- a/server/lib/activitypub/process/process-flag.ts
+++ b/server/lib/activitypub/process/process-flag.ts
@@ -4,10 +4,10 @@ import { VideoModel } from '@server/models/video/video'
4import { VideoCommentModel } from '@server/models/video/video-comment' 4import { VideoCommentModel } from '@server/models/video/video-comment'
5import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' 5import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
6import { AbuseObject, AbuseState, ActivityCreate, ActivityFlag } from '@shared/models' 6import { AbuseObject, AbuseState, ActivityCreate, ActivityFlag } from '@shared/models'
7import { getAPId } from '../../../helpers/activitypub'
8import { retryTransactionWrapper } from '../../../helpers/database-utils' 7import { retryTransactionWrapper } from '../../../helpers/database-utils'
9import { logger } from '../../../helpers/logger' 8import { logger } from '../../../helpers/logger'
10import { sequelizeTypescript } from '../../../initializers/database' 9import { sequelizeTypescript } from '../../../initializers/database'
10import { getAPId } from '../../../lib/activitypub/activity'
11import { APProcessorOptions } from '../../../types/activitypub-processor.model' 11import { APProcessorOptions } from '../../../types/activitypub-processor.model'
12import { MAccountDefault, MActorSignature, MCommentOwnerVideo } from '../../../types/models' 12import { MAccountDefault, MActorSignature, MCommentOwnerVideo } from '../../../types/models'
13 13
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index e44590ffc..93df7e191 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -1,10 +1,10 @@
1import { getServerActor } from '@server/models/application/application' 1import { getServerActor } from '@server/models/application/application'
2import { ActivityFollow } from '../../../../shared/models/activitypub' 2import { ActivityFollow } from '../../../../shared/models/activitypub'
3import { getAPId } from '../../../helpers/activitypub'
4import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
5import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
6import { CONFIG } from '../../../initializers/config' 5import { CONFIG } from '../../../initializers/config'
7import { sequelizeTypescript } from '../../../initializers/database' 6import { sequelizeTypescript } from '../../../initializers/database'
7import { getAPId } from '../../../lib/activitypub/activity'
8import { ActorModel } from '../../../models/actor/actor' 8import { ActorModel } from '../../../models/actor/actor'
9import { ActorFollowModel } from '../../../models/actor/actor-follow' 9import { ActorFollowModel } from '../../../models/actor/actor-follow'
10import { APProcessorOptions } from '../../../types/activitypub-processor.model' 10import { APProcessorOptions } from '../../../types/activitypub-processor.model'
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index 93afb5edf..1aee756d8 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -1,8 +1,8 @@
1import { VideoModel } from '@server/models/video/video' 1import { VideoModel } from '@server/models/video/video'
2import { ActivityLike } from '../../../../shared/models/activitypub' 2import { ActivityLike } from '../../../../shared/models/activitypub'
3import { getAPId } from '../../../helpers/activitypub'
4import { retryTransactionWrapper } from '../../../helpers/database-utils' 3import { retryTransactionWrapper } from '../../../helpers/database-utils'
5import { sequelizeTypescript } from '../../../initializers/database' 4import { sequelizeTypescript } from '../../../initializers/database'
5import { getAPId } from '../../../lib/activitypub/activity'
6import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 6import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
7import { APProcessorOptions } from '../../../types/activitypub-processor.model' 7import { APProcessorOptions } from '../../../types/activitypub-processor.model'
8import { MActorSignature } from '../../../types/models' 8import { MActorSignature } from '../../../types/models'
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index 02a23d098..2bc3dce03 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -1,10 +1,11 @@
1import { StatsManager } from '@server/lib/stat-manager' 1import { StatsManager } from '@server/lib/stat-manager'
2import { Activity, ActivityType } from '../../../../shared/models/activitypub' 2import { Activity, ActivityType } from '../../../../shared/models/activitypub'
3import { checkUrlsSameHost, getAPId } from '../../../helpers/activitypub'
4import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
5import { APProcessorOptions } from '../../../types/activitypub-processor.model' 4import { APProcessorOptions } from '../../../types/activitypub-processor.model'
6import { MActorDefault, MActorSignature } from '../../../types/models' 5import { MActorDefault, MActorSignature } from '../../../types/models'
6import { getAPId } from '../activity'
7import { getOrCreateAPActor } from '../actors' 7import { getOrCreateAPActor } from '../actors'
8import { checkUrlsSameHost } from '../url'
8import { processAcceptActivity } from './process-accept' 9import { processAcceptActivity } from './process-accept'
9import { processAnnounceActivity } from './process-announce' 10import { processAnnounceActivity } from './process-announce'
10import { processCreateActivity } from './process-create' 11import { processCreateActivity } from './process-create'
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index b18761174..0fefcbbc5 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,15 +1,15 @@
1import { map } from 'bluebird' 1import { map } from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
5import { logger, loggerTagsFactory } from '../../helpers/logger' 4import { logger, loggerTagsFactory } from '../../helpers/logger'
6import { doJSONRequest } from '../../helpers/requests' 5import { doJSONRequest } from '../../helpers/requests'
7import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' 6import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants'
8import { VideoShareModel } from '../../models/video/video-share' 7import { VideoShareModel } from '../../models/video/video-share'
9import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video' 8import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video'
9import { getAPId } from './activity'
10import { getOrCreateAPActor } from './actors' 10import { getOrCreateAPActor } from './actors'
11import { sendUndoAnnounce, sendVideoAnnounce } from './send' 11import { sendUndoAnnounce, sendVideoAnnounce } from './send'
12import { getLocalVideoAnnounceActivityPubUrl } from './url' 12import { checkUrlsSameHost, getLocalVideoAnnounceActivityPubUrl } from './url'
13 13
14const lTags = loggerTagsFactory('share') 14const lTags = loggerTagsFactory('share')
15 15
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts
index 338398f2b..50be4fac9 100644
--- a/server/lib/activitypub/url.ts
+++ b/server/lib/activitypub/url.ts
@@ -1,4 +1,4 @@
1import { WEBSERVER } from '../../initializers/constants' 1import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants'
2import { 2import {
3 MAbuseFull, 3 MAbuseFull,
4 MAbuseId, 4 MAbuseId,
@@ -10,7 +10,8 @@ import {
10 MVideoId, 10 MVideoId,
11 MVideoPlaylistElement, 11 MVideoPlaylistElement,
12 MVideoUrl, 12 MVideoUrl,
13 MVideoUUID 13 MVideoUUID,
14 MVideoWithHost
14} from '../../types/models' 15} from '../../types/models'
15import { MVideoFileVideoUUID } from '../../types/models/video/video-file' 16import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
16import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' 17import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
@@ -121,6 +122,27 @@ function getAbuseTargetUrl (abuse: MAbuseFull) {
121 abuse.FlaggedAccount.Actor.url 122 abuse.FlaggedAccount.Actor.url
122} 123}
123 124
125// ---------------------------------------------------------------------------
126
127function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
128 if (!scheme) scheme = REMOTE_SCHEME.HTTP
129
130 const host = video.VideoChannel.Actor.Server.host
131
132 return scheme + '://' + host + path
133}
134
135// ---------------------------------------------------------------------------
136
137function checkUrlsSameHost (url1: string, url2: string) {
138 const idHost = new URL(url1).host
139 const actorHost = new URL(url2).host
140
141 return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
142}
143
144// ---------------------------------------------------------------------------
145
124export { 146export {
125 getLocalVideoActivityPubUrl, 147 getLocalVideoActivityPubUrl,
126 getLocalVideoPlaylistActivityPubUrl, 148 getLocalVideoPlaylistActivityPubUrl,
@@ -145,5 +167,8 @@ export {
145 getLocalVideoCommentsActivityPubUrl, 167 getLocalVideoCommentsActivityPubUrl,
146 getLocalVideoLikesActivityPubUrl, 168 getLocalVideoLikesActivityPubUrl,
147 getLocalVideoDislikesActivityPubUrl, 169 getLocalVideoDislikesActivityPubUrl,
148 getAbuseTargetUrl 170
171 getAbuseTargetUrl,
172 checkUrlsSameHost,
173 buildRemoteVideoBaseUrl
149} 174}
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 2c7da3e00..911c7cd30 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -1,5 +1,4 @@
1import { map } from 'bluebird' 1import { map } from 'bluebird'
2import { checkUrlsSameHost } from '../../helpers/activitypub'
3import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' 2import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
4import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
5import { doJSONRequest } from '../../helpers/requests' 4import { doJSONRequest } from '../../helpers/requests'
@@ -7,6 +6,7 @@ import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers/cons
7import { VideoCommentModel } from '../../models/video/video-comment' 6import { VideoCommentModel } from '../../models/video/video-comment'
8import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../types/models/video' 7import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../types/models/video'
9import { getOrCreateAPActor } from './actors' 8import { getOrCreateAPActor } from './actors'
9import { checkUrlsSameHost } from './url'
10import { getOrCreateAPVideo } from './videos' 10import { getOrCreateAPVideo } from './videos'
11 11
12type ResolveThreadParams = { 12type ResolveThreadParams = {
diff --git a/server/lib/activitypub/videos/get.ts b/server/lib/activitypub/videos/get.ts
index b13c6ceeb..d7500c71a 100644
--- a/server/lib/activitypub/videos/get.ts
+++ b/server/lib/activitypub/videos/get.ts
@@ -1,9 +1,9 @@
1import { getAPId } from '@server/helpers/activitypub'
2import { retryTransactionWrapper } from '@server/helpers/database-utils' 1import { retryTransactionWrapper } from '@server/helpers/database-utils'
3import { JobQueue } from '@server/lib/job-queue' 2import { JobQueue } from '@server/lib/job-queue'
4import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders' 3import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders'
5import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models' 4import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models'
6import { APObject } from '@shared/models' 5import { APObject } from '@shared/models'
6import { getAPId } from '../activity'
7import { refreshVideoIfNeeded } from './refresh' 7import { refreshVideoIfNeeded } from './refresh'
8import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' 8import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
9 9
diff --git a/server/lib/activitypub/videos/shared/abstract-builder.ts b/server/lib/activitypub/videos/shared/abstract-builder.ts
index 788223b48..f299ba4fd 100644
--- a/server/lib/activitypub/videos/shared/abstract-builder.ts
+++ b/server/lib/activitypub/videos/shared/abstract-builder.ts
@@ -1,5 +1,4 @@
1import { Transaction } from 'sequelize/types' 1import { Transaction } from 'sequelize/types'
2import { checkUrlsSameHost } from '@server/helpers/activitypub'
3import { deleteAllModels, filterNonExistingModels } from '@server/helpers/database-utils' 2import { deleteAllModels, filterNonExistingModels } from '@server/helpers/database-utils'
4import { logger, LoggerTagsFn } from '@server/helpers/logger' 3import { logger, LoggerTagsFn } from '@server/helpers/logger'
5import { updatePlaceholderThumbnail, updateVideoMiniatureFromUrl } from '@server/lib/thumbnail' 4import { updatePlaceholderThumbnail, updateVideoMiniatureFromUrl } from '@server/lib/thumbnail'
@@ -11,6 +10,7 @@ import { VideoStreamingPlaylistModel } from '@server/models/video/video-streamin
11import { MStreamingPlaylistFilesVideo, MThumbnail, MVideoCaption, MVideoFile, MVideoFullLight, MVideoThumbnail } from '@server/types/models' 10import { MStreamingPlaylistFilesVideo, MThumbnail, MVideoCaption, MVideoFile, MVideoFullLight, MVideoThumbnail } from '@server/types/models'
12import { ActivityTagObject, ThumbnailType, VideoObject, VideoStreamingPlaylistType } from '@shared/models' 11import { ActivityTagObject, ThumbnailType, VideoObject, VideoStreamingPlaylistType } from '@shared/models'
13import { getOrCreateAPActor } from '../../actors' 12import { getOrCreateAPActor } from '../../actors'
13import { checkUrlsSameHost } from '../../url'
14import { 14import {
15 getCaptionAttributesFromObject, 15 getCaptionAttributesFromObject,
16 getFileAttributesFromUrl, 16 getFileAttributesFromUrl,
diff --git a/server/lib/activitypub/videos/shared/trackers.ts b/server/lib/activitypub/videos/shared/trackers.ts
index 1c5fc4f84..2418f45c2 100644
--- a/server/lib/activitypub/videos/shared/trackers.ts
+++ b/server/lib/activitypub/videos/shared/trackers.ts
@@ -1,11 +1,11 @@
1import { Transaction } from 'sequelize/types' 1import { Transaction } from 'sequelize/types'
2import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
3import { isAPVideoTrackerUrlObject } from '@server/helpers/custom-validators/activitypub/videos' 2import { isAPVideoTrackerUrlObject } from '@server/helpers/custom-validators/activitypub/videos'
4import { isArray } from '@server/helpers/custom-validators/misc' 3import { isArray } from '@server/helpers/custom-validators/misc'
5import { REMOTE_SCHEME } from '@server/initializers/constants' 4import { REMOTE_SCHEME } from '@server/initializers/constants'
6import { TrackerModel } from '@server/models/server/tracker' 5import { TrackerModel } from '@server/models/server/tracker'
7import { MVideo, MVideoWithHost } from '@server/types/models' 6import { MVideo, MVideoWithHost } from '@server/types/models'
8import { ActivityTrackerUrlObject, VideoObject } from '@shared/models' 7import { ActivityTrackerUrlObject, VideoObject } from '@shared/models'
8import { buildRemoteVideoBaseUrl } from '../../url'
9 9
10function getTrackerUrls (object: VideoObject, video: MVideoWithHost) { 10function getTrackerUrls (object: VideoObject, video: MVideoWithHost) {
11 let wsFound = false 11 let wsFound = false
diff --git a/server/lib/activitypub/videos/shared/url-to-object.ts b/server/lib/activitypub/videos/shared/url-to-object.ts
index dba3e9480..5b7007530 100644
--- a/server/lib/activitypub/videos/shared/url-to-object.ts
+++ b/server/lib/activitypub/videos/shared/url-to-object.ts
@@ -1,8 +1,8 @@
1import { checkUrlsSameHost } from '@server/helpers/activitypub'
2import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos' 1import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 2import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { doJSONRequest } from '@server/helpers/requests' 3import { doJSONRequest } from '@server/helpers/requests'
5import { VideoObject } from '@shared/models' 4import { VideoObject } from '@shared/models'
5import { checkUrlsSameHost } from '../../url'
6 6
7const lTags = loggerTagsFactory('ap', 'video') 7const lTags = loggerTagsFactory('ap', 'video')
8 8
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 07dd908cd..123aeac03 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -1,6 +1,5 @@
1import { map } from 'bluebird' 1import { map } from 'bluebird'
2import { Job } from 'bull' 2import { Job } from 'bull'
3import { checkUrlsSameHost } from '@server/helpers/activitypub'
4import { 3import {
5 isAnnounceActivityValid, 4 isAnnounceActivityValid,
6 isDislikeActivityValid, 5 isDislikeActivityValid,
@@ -9,6 +8,7 @@ import {
9import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments' 8import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments'
10import { doJSONRequest, PeerTubeRequestError } from '@server/helpers/requests' 9import { doJSONRequest, PeerTubeRequestError } from '@server/helpers/requests'
11import { AP_CLEANER } from '@server/initializers/constants' 10import { AP_CLEANER } from '@server/initializers/constants'
11import { checkUrlsSameHost } from '@server/lib/activitypub/url'
12import { Redis } from '@server/lib/redis' 12import { Redis } from '@server/lib/redis'
13import { VideoModel } from '@server/models/video/video' 13import { VideoModel } from '@server/models/video/video'
14import { VideoCommentModel } from '@server/models/video/video-comment' 14import { VideoCommentModel } from '@server/models/video/video-comment'
diff --git a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts
index 37e7c1fad..2a03325b7 100644
--- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts
+++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts
@@ -1,7 +1,7 @@
1import { buildDigest } from '@server/helpers/peertube-crypto' 1import { buildDigest } from '@server/helpers/peertube-crypto'
2import { buildSignedActivity } from '@server/lib/activitypub/activity'
2import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
3import { ContextType } from '@shared/models/activitypub/context' 4import { ContextType } from '@shared/models/activitypub/context'
4import { buildSignedActivity } from '../../../../helpers/activitypub'
5import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants' 5import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants'
6import { ActorModel } from '../../../../models/actor/actor' 6import { ActorModel } from '../../../../models/actor/actor'
7import { MActor } from '../../../../types/models' 7import { MActor } from '../../../../types/models'
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 86d3c1d6c..2a2d86a24 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -1,6 +1,6 @@
1import { NextFunction, Request, Response } from 'express' 1import { NextFunction, Request, Response } from 'express'
2import { getAPId } from '@server/helpers/activitypub'
3import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' 2import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
3import { getAPId } from '@server/lib/activitypub/activity'
4import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@shared/models' 4import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@shared/models'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' 6import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
diff --git a/server/models/actor/actor.ts b/server/models/actor/actor.ts
index 08cb2fd24..fad2070ea 100644
--- a/server/models/actor/actor.ts
+++ b/server/models/actor/actor.ts
@@ -16,12 +16,12 @@ import {
16 Table, 16 Table,
17 UpdatedAt 17 UpdatedAt
18} from 'sequelize-typescript' 18} from 'sequelize-typescript'
19import { activityPubContextify } from '@server/lib/activitypub/context'
19import { getBiggestActorImage } from '@server/lib/actor-image' 20import { getBiggestActorImage } from '@server/lib/actor-image'
20import { ModelCache } from '@server/models/model-cache' 21import { ModelCache } from '@server/models/model-cache'
21import { getLowercaseExtension } from '@shared/core-utils' 22import { getLowercaseExtension } from '@shared/core-utils'
22import { ActivityIconObject, ActivityPubActorType, ActorImageType } from '@shared/models' 23import { ActivityIconObject, ActivityPubActorType, ActorImageType } from '@shared/models'
23import { AttributesOnly } from '@shared/typescript-utils' 24import { AttributesOnly } from '@shared/typescript-utils'
24import { activityPubContextify } from '../../helpers/activitypub'
25import { 25import {
26 isActorFollowersCountValid, 26 isActorFollowersCountValid,
27 isActorFollowingCountValid, 27 isActorFollowingCountValid,
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index fae76c6f2..4aaee1ffa 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -19,9 +19,9 @@ import {
19 UpdatedAt 19 UpdatedAt
20} from 'sequelize-typescript' 20} from 'sequelize-typescript'
21import validator from 'validator' 21import validator from 'validator'
22import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
23import { logger } from '@server/helpers/logger' 22import { logger } from '@server/helpers/logger'
24import { extractVideo } from '@server/helpers/video' 23import { extractVideo } from '@server/helpers/video'
24import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url'
25import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage' 25import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage'
26import { getFSTorrentFilePath } from '@server/lib/paths' 26import { getFSTorrentFilePath } from '@server/lib/paths'
27import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' 27import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models'
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index ae5e237ec..8fb3d5f15 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -17,6 +17,7 @@ import {
17 Table, 17 Table,
18 UpdatedAt 18 UpdatedAt
19} from 'sequelize-typescript' 19} from 'sequelize-typescript'
20import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
20import { MAccountId, MChannelId } from '@server/types/models' 21import { MAccountId, MChannelId } from '@server/types/models'
21import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils' 22import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'
22import { buildUUID, uuidToShort } from '@shared/extra-utils' 23import { buildUUID, uuidToShort } from '@shared/extra-utils'
@@ -26,7 +27,6 @@ import { PlaylistObject } from '../../../shared/models/activitypub/objects/playl
26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 27import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
27import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' 28import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model'
28import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' 29import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model'
29import { activityPubCollectionPagination } from '../../helpers/activitypub'
30import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 30import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
31import { 31import {
32 isVideoPlaylistDescriptionValid, 32 isVideoPlaylistDescriptionValid,
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts
index 25e1d9823..e516cf49e 100644
--- a/server/tests/api/activitypub/helpers.ts
+++ b/server/tests/api/activitypub/helpers.ts
@@ -5,8 +5,8 @@ import { expect } from 'chai'
5import { cloneDeep } from 'lodash' 5import { cloneDeep } from 'lodash'
6import { buildRequestStub } from '@server/tests/shared' 6import { buildRequestStub } from '@server/tests/shared'
7import { buildAbsoluteFixturePath } from '@shared/core-utils' 7import { buildAbsoluteFixturePath } from '@shared/core-utils'
8import { buildSignedActivity } from '../../../helpers/activitypub'
9import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' 8import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
9import { buildSignedActivity } from '../../../lib/activitypub/activity'
10 10
11describe('Test activity pub helpers', function () { 11describe('Test activity pub helpers', function () {
12 describe('When checking the Linked Signature', function () { 12 describe('When checking the Linked Signature', function () {
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c4cb5ea0d..da9880d7d 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -2,9 +2,10 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { activityPubContextify, buildSignedActivity } from '@server/helpers/activitypub'
6import { buildDigest } from '@server/helpers/peertube-crypto' 5import { buildDigest } from '@server/helpers/peertube-crypto'
7import { HTTP_SIGNATURE } from '@server/initializers/constants' 6import { HTTP_SIGNATURE } from '@server/initializers/constants'
7import { buildSignedActivity } from '@server/lib/activitypub/activity'
8import { activityPubContextify } from '@server/lib/activitypub/context'
8import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' 9import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
9import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared' 10import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared'
10import { buildAbsoluteFixturePath, wait } from '@shared/core-utils' 11import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
diff --git a/server/tests/shared/requests.ts b/server/tests/shared/requests.ts
index 7f1acc0e1..d7aedf82f 100644
--- a/server/tests/shared/requests.ts
+++ b/server/tests/shared/requests.ts
@@ -1,7 +1,7 @@
1import { activityPubContextify } from '@server/helpers/activitypub'
2import { buildDigest } from '@server/helpers/peertube-crypto' 1import { buildDigest } from '@server/helpers/peertube-crypto'
3import { doRequest } from '@server/helpers/requests' 2import { doRequest } from '@server/helpers/requests'
4import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants' 3import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants'
4import { activityPubContextify } from '@server/lib/activitypub/context'
5 5
6export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { 6export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
7 const options = { 7 const options = {