diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-23 09:32:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 8dc8a34ee8428e7657414115d1c137592efa174d (patch) | |
tree | e9b5ef0d7446d1b7766eac18da5a759edc7a9040 | |
parent | 7fed637506043e4432cbebe041ada0625171cceb (diff) | |
download | PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.gz PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.zst PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.zip |
Avoir some circular dependencies
69 files changed, 278 insertions, 263 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index fec58da2e..1312e8952 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -5,8 +5,8 @@ import * as program from 'commander' | |||
5 | import { VideoModel } from '../server/models/video/video' | 5 | import { VideoModel } from '../server/models/video/video' |
6 | import { initDatabaseModels } from '../server/initializers' | 6 | import { initDatabaseModels } from '../server/initializers' |
7 | import { JobQueue } from '../server/lib/job-queue' | 7 | import { JobQueue } from '../server/lib/job-queue' |
8 | import { VideoTranscodingPayload } from '../server/lib/job-queue/handlers/video-transcoding' | ||
9 | import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg-utils' | 8 | import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg-utils' |
9 | import { VideoTranscodingPayload } from '@shared/models' | ||
10 | 10 | ||
11 | program | 11 | program |
12 | .option('-v, --video [videoUUID]', 'Video UUID') | 12 | .option('-v, --video [videoUUID]', 'Video UUID') |
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index c3aeeebf5..e44f1c6ab 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -24,20 +24,20 @@ import { cacheRoute } from '../../middlewares/cache' | |||
24 | import { activityPubResponse } from './utils' | 24 | import { activityPubResponse } from './utils' |
25 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 25 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
26 | import { | 26 | import { |
27 | getRateUrl, | ||
28 | getVideoCommentsActivityPubUrl, | 27 | getVideoCommentsActivityPubUrl, |
29 | getVideoDislikesActivityPubUrl, | 28 | getVideoDislikesActivityPubUrl, |
30 | getVideoLikesActivityPubUrl, | 29 | getVideoLikesActivityPubUrl, |
31 | getVideoSharesActivityPubUrl | 30 | getVideoSharesActivityPubUrl |
32 | } from '../../lib/activitypub' | 31 | } from '../../lib/activitypub/url' |
33 | import { VideoCaptionModel } from '../../models/video/video-caption' | 32 | import { VideoCaptionModel } from '../../models/video/video-caption' |
34 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 33 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
35 | import { getServerActor } from '../../helpers/utils' | ||
36 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' | 34 | import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' |
37 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 35 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
38 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 36 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
39 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 37 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
40 | import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' | 38 | import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' |
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | import { getRateUrl } from '@server/lib/activitypub/video-rates' | ||
41 | 41 | ||
42 | const activityPubClientRouter = express.Router() | 42 | const activityPubClientRouter = express.Router() |
43 | activityPubClientRouter.use(cors()) | 43 | activityPubClientRouter.use(cors()) |
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index f8d2bad8b..3bbb0a43e 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' | 2 | import { getFormattedObjects} from '../../helpers/utils' |
3 | import { | 3 | import { |
4 | asyncMiddleware, | 4 | asyncMiddleware, |
5 | authenticate, | 5 | authenticate, |
@@ -28,6 +28,7 @@ import { VideoChannelModel } from '../../models/video/video-channel' | |||
28 | import { JobQueue } from '../../lib/job-queue' | 28 | import { JobQueue } from '../../lib/job-queue' |
29 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 29 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
30 | import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists' | 30 | import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists' |
31 | import { getServerActor } from '@server/models/application/application' | ||
31 | 32 | ||
32 | const accountsRouter = express.Router() | 33 | const accountsRouter = express.Router() |
33 | 34 | ||
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index 16ffbf683..35d94d747 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 2 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
3 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' | 3 | import { getFormattedObjects } from '../../helpers/utils' |
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
5 | import { | 5 | import { |
6 | asyncMiddleware, | 6 | asyncMiddleware, |
@@ -15,11 +15,13 @@ import { | |||
15 | videosSearchValidator | 15 | videosSearchValidator |
16 | } from '../../middlewares' | 16 | } from '../../middlewares' |
17 | import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/models/search' | 17 | import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/models/search' |
18 | import { getOrCreateActorAndServerAndModel, getOrCreateVideoAndAccountAndChannel } from '../../lib/activitypub' | 18 | import { getOrCreateActorAndServerAndModel } from '../../lib/activitypub/actor' |
19 | import { logger } from '../../helpers/logger' | 19 | import { logger } from '../../helpers/logger' |
20 | import { VideoChannelModel } from '../../models/video/video-channel' | 20 | import { VideoChannelModel } from '../../models/video/video-channel' |
21 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' | 21 | import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' |
22 | import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../../typings/models' | 22 | import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../../typings/models' |
23 | import { getServerActor } from '@server/models/application/application' | ||
24 | import { getOrCreateVideoAndAccountAndChannel } from '@server/lib/activitypub/videos' | ||
23 | 25 | ||
24 | const searchRouter = express.Router() | 26 | const searchRouter = express.Router() |
25 | 27 | ||
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 0bc20bd60..82e9ef898 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserRight } from '../../../../shared/models/users' | 2 | import { UserRight } from '../../../../shared/models/users' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 4 | import { getFormattedObjects} from '../../../helpers/utils' |
5 | import { SERVER_ACTOR_NAME } from '../../../initializers/constants' | 5 | import { SERVER_ACTOR_NAME } from '../../../initializers/constants' |
6 | import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' | 6 | import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send' |
7 | import { | 7 | import { |
@@ -27,6 +27,7 @@ import { JobQueue } from '../../../lib/job-queue' | |||
27 | import { removeRedundanciesOfServer } from '../../../lib/redundancy' | 27 | import { removeRedundanciesOfServer } from '../../../lib/redundancy' |
28 | import { sequelizeTypescript } from '../../../initializers/database' | 28 | import { sequelizeTypescript } from '../../../initializers/database' |
29 | import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' | 29 | import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' |
30 | import { getServerActor } from '@server/models/application/application' | ||
30 | 31 | ||
31 | const serverFollowsRouter = express.Router() | 32 | const serverFollowsRouter = express.Router() |
32 | serverFollowsRouter.get('/following', | 33 | serverFollowsRouter.get('/following', |
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts index ffb7814fa..008b8d4ea 100644 --- a/server/controllers/api/server/server-blocklist.ts +++ b/server/controllers/api/server/server-blocklist.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'multer' | 2 | import 'multer' |
3 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 3 | import { getFormattedObjects} from '../../../helpers/utils' |
4 | import { | 4 | import { |
5 | asyncMiddleware, | 5 | asyncMiddleware, |
6 | asyncRetryTransactionMiddleware, | 6 | asyncRetryTransactionMiddleware, |
@@ -22,6 +22,7 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist | |||
22 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' | 22 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' |
23 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' | 23 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' |
24 | import { UserRight } from '../../../../shared/models/users' | 24 | import { UserRight } from '../../../../shared/models/users' |
25 | import { getServerActor } from '@server/models/application/application' | ||
25 | 26 | ||
26 | const serverBlocklistRouter = express.Router() | 27 | const serverBlocklistRouter = express.Router() |
27 | 28 | ||
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index a808896ff..faef5ba4b 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' | 2 | import { getFormattedObjects} from '../../helpers/utils' |
3 | import { | 3 | import { |
4 | asyncMiddleware, | 4 | asyncMiddleware, |
5 | asyncRetryTransactionMiddleware, | 5 | asyncRetryTransactionMiddleware, |
@@ -21,7 +21,7 @@ import { sendUpdateActor } from '../../lib/activitypub/send' | |||
21 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' | 21 | import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared' |
22 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' | 22 | import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel' |
23 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 23 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
24 | import { setAsyncActorKeys } from '../../lib/activitypub' | 24 | import { setAsyncActorKeys } from '../../lib/activitypub/actor' |
25 | import { AccountModel } from '../../models/account/account' | 25 | import { AccountModel } from '../../models/account/account' |
26 | import { MIMETYPES } from '../../initializers/constants' | 26 | import { MIMETYPES } from '../../initializers/constants' |
27 | import { logger } from '../../helpers/logger' | 27 | import { logger } from '../../helpers/logger' |
@@ -36,6 +36,7 @@ import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validator | |||
36 | import { CONFIG } from '../../initializers/config' | 36 | import { CONFIG } from '../../initializers/config' |
37 | import { sequelizeTypescript } from '../../initializers/database' | 37 | import { sequelizeTypescript } from '../../initializers/database' |
38 | import { MChannelAccountDefault } from '@server/typings/models' | 38 | import { MChannelAccountDefault } from '@server/typings/models' |
39 | import { getServerActor } from '@server/models/application/application' | ||
39 | 40 | ||
40 | const auditLogger = auditLoggerFactory('channels') | 41 | const auditLogger = auditLoggerFactory('channels') |
41 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 42 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) |
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index aa9053372..49ac3c80e 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getFormattedObjects, getServerActor } from '../../helpers/utils' | 2 | import { getFormattedObjects} from '../../helpers/utils' |
3 | import { | 3 | import { |
4 | asyncMiddleware, | 4 | asyncMiddleware, |
5 | asyncRetryTransactionMiddleware, | 5 | asyncRetryTransactionMiddleware, |
@@ -41,6 +41,7 @@ import { CONFIG } from '../../initializers/config' | |||
41 | import { sequelizeTypescript } from '../../initializers/database' | 41 | import { sequelizeTypescript } from '../../initializers/database' |
42 | import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' | 42 | import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' |
43 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/typings/models' | 43 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/typings/models' |
44 | import { getServerActor } from '@server/models/application/application' | ||
44 | 45 | ||
45 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) | 46 | const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) |
46 | 47 | ||
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index f37d90896..bc7df48c8 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserRight, VideoAbuseCreate, VideoAbuseState } from '../../../../shared' | 2 | import { UserRight, VideoAbuseCreate, VideoAbuseState } from '../../../../shared' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 4 | import { getFormattedObjects } from '../../../helpers/utils' |
5 | import { sequelizeTypescript } from '../../../initializers' | 5 | import { sequelizeTypescript } from '../../../initializers' |
6 | import { | 6 | import { |
7 | asyncMiddleware, | 7 | asyncMiddleware, |
@@ -22,6 +22,7 @@ import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit- | |||
22 | import { Notifier } from '../../../lib/notifier' | 22 | import { Notifier } from '../../../lib/notifier' |
23 | import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag' | 23 | import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag' |
24 | import { MVideoAbuseAccountVideo } from '../../../typings/models/video' | 24 | import { MVideoAbuseAccountVideo } from '../../../typings/models/video' |
25 | import { getServerActor } from '@server/models/application/application' | ||
25 | 26 | ||
26 | const auditLogger = auditLoggerFactory('abuse') | 27 | const auditLogger = auditLoggerFactory('abuse') |
27 | const abuseVideoRouter = express.Router() | 28 | const abuseVideoRouter = express.Router() |
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index c4aa79cd2..abd09387c 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -19,7 +19,7 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | |||
19 | import { sequelizeTypescript } from '../../../initializers' | 19 | import { sequelizeTypescript } from '../../../initializers' |
20 | import { Notifier } from '../../../lib/notifier' | 20 | import { Notifier } from '../../../lib/notifier' |
21 | import { sendDeleteVideo } from '../../../lib/activitypub/send' | 21 | import { sendDeleteVideo } from '../../../lib/activitypub/send' |
22 | import { federateVideoIfNeeded } from '../../../lib/activitypub' | 22 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
23 | import { MVideoBlacklistVideo } from '@server/typings/models' | 23 | import { MVideoBlacklistVideo } from '@server/typings/models' |
24 | 24 | ||
25 | const blacklistRouter = express.Router() | 25 | const blacklistRouter = express.Router() |
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index fd7b165fb..8c1d12ca8 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts | |||
@@ -6,7 +6,7 @@ import { MIMETYPES } from '../../../initializers/constants' | |||
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
7 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 7 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
8 | import { logger } from '../../../helpers/logger' | 8 | import { logger } from '../../../helpers/logger' |
9 | import { federateVideoIfNeeded } from '../../../lib/activitypub' | 9 | import { federateVideoIfNeeded } from '../../../lib/activitypub/videos' |
10 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 10 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
11 | import { CONFIG } from '../../../initializers/config' | 11 | import { CONFIG } from '../../../initializers/config' |
12 | import { sequelizeTypescript } from '../../../initializers/database' | 12 | import { sequelizeTypescript } from '../../../initializers/database' |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index be96ef42c..b4f70a086 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -10,7 +10,7 @@ import { VideoImportCreate, VideoImportState, VideoPrivacy, VideoState } from '. | |||
10 | import { VideoModel } from '../../../models/video/video' | 10 | import { VideoModel } from '../../../models/video/video' |
11 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 11 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
12 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 12 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
13 | import { getVideoActivityPubUrl } from '../../../lib/activitypub' | 13 | import { getVideoActivityPubUrl } from '../../../lib/activitypub/url' |
14 | import { TagModel } from '../../../models/video/tag' | 14 | import { TagModel } from '../../../models/video/tag' |
15 | import { VideoImportModel } from '../../../models/video/video-import' | 15 | import { VideoImportModel } from '../../../models/video/video-import' |
16 | import { JobQueue } from '../../../lib/job-queue/job-queue' | 16 | import { JobQueue } from '../../../lib/job-queue/job-queue' |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 04d775cbf..8048c568c 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -4,7 +4,7 @@ import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../ | |||
4 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 4 | import { getMetadataFromFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 6 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
7 | import { getFormattedObjects, getServerActor } from '../../../helpers/utils' | 7 | import { getFormattedObjects } from '../../../helpers/utils' |
8 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | 8 | import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' |
9 | import { | 9 | import { |
10 | DEFAULT_AUDIO_RESOLUTION, | 10 | DEFAULT_AUDIO_RESOLUTION, |
@@ -14,12 +14,7 @@ import { | |||
14 | VIDEO_LICENCES, | 14 | VIDEO_LICENCES, |
15 | VIDEO_PRIVACIES | 15 | VIDEO_PRIVACIES |
16 | } from '../../../initializers/constants' | 16 | } from '../../../initializers/constants' |
17 | import { | 17 | import { federateVideoIfNeeded, fetchRemoteVideoDescription } from '../../../lib/activitypub/videos' |
18 | changeVideoChannelShare, | ||
19 | federateVideoIfNeeded, | ||
20 | fetchRemoteVideoDescription, | ||
21 | getVideoActivityPubUrl | ||
22 | } from '../../../lib/activitypub' | ||
23 | import { JobQueue } from '../../../lib/job-queue' | 18 | import { JobQueue } from '../../../lib/job-queue' |
24 | import { Redis } from '../../../lib/redis' | 19 | import { Redis } from '../../../lib/redis' |
25 | import { | 20 | import { |
@@ -67,7 +62,10 @@ import { MVideoDetails, MVideoFullLight } from '@server/typings/models' | |||
67 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 62 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
68 | import { getVideoFilePath } from '@server/lib/video-paths' | 63 | import { getVideoFilePath } from '@server/lib/video-paths' |
69 | import toInt from 'validator/lib/toInt' | 64 | import toInt from 'validator/lib/toInt' |
70 | import { addOptimizeOrMergeAudioJob } from '@server/lib/videos' | 65 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' |
66 | import { getServerActor } from '@server/models/application/application' | ||
67 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | ||
68 | import { getVideoActivityPubUrl } from '@server/lib/activitypub/url' | ||
71 | 69 | ||
72 | const auditLogger = auditLoggerFactory('videos') | 70 | const auditLogger = auditLoggerFactory('videos') |
73 | const videosRouter = express.Router() | 71 | const videosRouter = express.Router() |
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index 41d7cdc43..190036f85 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts | |||
@@ -15,7 +15,7 @@ import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ow | |||
15 | import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' | 15 | import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' |
16 | import { VideoChannelModel } from '../../../models/video/video-channel' | 16 | import { VideoChannelModel } from '../../../models/video/video-channel' |
17 | import { getFormattedObjects } from '../../../helpers/utils' | 17 | import { getFormattedObjects } from '../../../helpers/utils' |
18 | import { changeVideoChannelShare } from '../../../lib/activitypub' | 18 | import { changeVideoChannelShare } from '../../../lib/activitypub/share' |
19 | import { sendUpdateVideo } from '../../../lib/activitypub/send' | 19 | import { sendUpdateVideo } from '../../../lib/activitypub/send' |
20 | import { VideoModel } from '../../../models/video/video' | 20 | import { VideoModel } from '../../../models/video/video' |
21 | import { MVideoFullLight } from '@server/typings/models' | 21 | import { MVideoFullLight } from '@server/typings/models' |
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 3d2f3d728..3ee365289 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { UserVideoRateUpdate } from '../../../../shared' | 2 | import { UserVideoRateUpdate } from '../../../../shared' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { VIDEO_RATE_TYPES } from '../../../initializers/constants' | 4 | import { VIDEO_RATE_TYPES } from '../../../initializers/constants' |
5 | import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub' | 5 | import { getRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' |
6 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' | 6 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' |
7 | import { AccountModel } from '../../../models/account/account' | 7 | import { AccountModel } from '../../../models/account/account' |
8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index 89c0ab151..394e97fd5 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts | |||
@@ -5,7 +5,6 @@ import { jsonld } from './custom-jsonld-signature' | |||
5 | import { logger } from './logger' | 5 | import { logger } from './logger' |
6 | import { cloneDeep } from 'lodash' | 6 | import { cloneDeep } from 'lodash' |
7 | import { createSign, createVerify } from 'crypto' | 7 | import { createSign, createVerify } from 'crypto' |
8 | import { buildDigest } from '../lib/job-queue/handlers/utils/activitypub-http-utils' | ||
9 | import * as bcrypt from 'bcrypt' | 8 | import * as bcrypt from 'bcrypt' |
10 | import { MActor } from '../typings/models' | 9 | import { MActor } from '../typings/models' |
11 | 10 | ||
@@ -104,12 +103,19 @@ async function signJsonLDObject (byActor: MActor, data: any) { | |||
104 | return Object.assign(data, { signature }) | 103 | return Object.assign(data, { signature }) |
105 | } | 104 | } |
106 | 105 | ||
106 | function buildDigest (body: any) { | ||
107 | const rawBody = typeof body === 'string' ? body : JSON.stringify(body) | ||
108 | |||
109 | return 'SHA-256=' + sha256(rawBody, 'base64') | ||
110 | } | ||
111 | |||
107 | // --------------------------------------------------------------------------- | 112 | // --------------------------------------------------------------------------- |
108 | 113 | ||
109 | export { | 114 | export { |
110 | isHTTPSignatureDigestValid, | 115 | isHTTPSignatureDigestValid, |
111 | parseHTTPSignature, | 116 | parseHTTPSignature, |
112 | isHTTPSignatureVerified, | 117 | isHTTPSignatureVerified, |
118 | buildDigest, | ||
113 | isJsonLDSignatureVerified, | 119 | isJsonLDSignatureVerified, |
114 | comparePassword, | 120 | comparePassword, |
115 | createPrivateAndPublicKeys, | 121 | createPrivateAndPublicKeys, |
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 11c118292..ad3b7949e 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -1,11 +1,9 @@ | |||
1 | import { ResultList } from '../../shared' | 1 | import { ResultList } from '../../shared' |
2 | import { ApplicationModel } from '../models/application/application' | ||
3 | import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' | 2 | import { execPromise, execPromise2, randomBytesPromise, sha256 } from './core-utils' |
4 | import { logger } from './logger' | 3 | import { logger } from './logger' |
5 | import { join } from 'path' | 4 | import { join } from 'path' |
6 | import { Instance as ParseTorrent } from 'parse-torrent' | 5 | import { Instance as ParseTorrent } from 'parse-torrent' |
7 | import { remove } from 'fs-extra' | 6 | import { remove } from 'fs-extra' |
8 | import * as memoizee from 'memoizee' | ||
9 | import { CONFIG } from '../initializers/config' | 7 | import { CONFIG } from '../initializers/config' |
10 | import { isVideoFileExtnameValid } from './custom-validators/videos' | 8 | import { isVideoFileExtnameValid } from './custom-validators/videos' |
11 | 9 | ||
@@ -33,16 +31,6 @@ function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: | |||
33 | } as ResultList<V> | 31 | } as ResultList<V> |
34 | } | 32 | } |
35 | 33 | ||
36 | const getServerActor = memoizee(async function () { | ||
37 | const application = await ApplicationModel.load() | ||
38 | if (!application) throw Error('Could not load Application from database.') | ||
39 | |||
40 | const actor = application.Account.Actor | ||
41 | actor.Account = application.Account | ||
42 | |||
43 | return actor | ||
44 | }, { promise: true }) | ||
45 | |||
46 | function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) { | 34 | function generateVideoImportTmpPath (target: string | ParseTorrent, extensionArg?: string) { |
47 | const id = typeof target === 'string' | 35 | const id = typeof target === 'string' |
48 | ? target | 36 | ? target |
@@ -105,7 +93,6 @@ export { | |||
105 | generateRandomString, | 93 | generateRandomString, |
106 | getFormattedObjects, | 94 | getFormattedObjects, |
107 | getSecureTorrentName, | 95 | getSecureTorrentName, |
108 | getServerActor, | ||
109 | getServerCommit, | 96 | getServerCommit, |
110 | generateVideoImportTmpPath, | 97 | generateVideoImportTmpPath, |
111 | getUUIDFromFilename | 98 | getUUIDFromFilename |
diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 4fe2a60f0..6f76cbdfc 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts | |||
@@ -1,14 +1,21 @@ | |||
1 | import { VideoModel } from '../models/video/video' | 1 | import { VideoModel } from '../models/video/video' |
2 | import * as Bluebird from 'bluebird' | 2 | import * as Bluebird from 'bluebird' |
3 | import { | 3 | import { |
4 | isStreamingPlaylist, | ||
5 | MStreamingPlaylistVideo, | ||
6 | MVideo, | ||
4 | MVideoAccountLightBlacklistAllFiles, | 7 | MVideoAccountLightBlacklistAllFiles, |
8 | MVideoFile, | ||
5 | MVideoFullLight, | 9 | MVideoFullLight, |
6 | MVideoIdThumbnail, | 10 | MVideoIdThumbnail, |
11 | MVideoImmutable, | ||
7 | MVideoThumbnail, | 12 | MVideoThumbnail, |
8 | MVideoWithRights, | 13 | MVideoWithRights |
9 | MVideoImmutable | ||
10 | } from '@server/typings/models' | 14 | } from '@server/typings/models' |
11 | import { Response } from 'express' | 15 | import { Response } from 'express' |
16 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | ||
17 | import { JobQueue } from '@server/lib/job-queue' | ||
18 | import { VideoTranscodingPayload } from '@shared/models' | ||
12 | 19 | ||
13 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 20 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
14 | 21 | ||
@@ -62,10 +69,39 @@ function getVideoWithAttributes (res: Response) { | |||
62 | return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights | 69 | return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights |
63 | } | 70 | } |
64 | 71 | ||
72 | function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) { | ||
73 | let dataInput: VideoTranscodingPayload | ||
74 | |||
75 | if (videoFile.isAudio()) { | ||
76 | dataInput = { | ||
77 | type: 'merge-audio' as 'merge-audio', | ||
78 | resolution: DEFAULT_AUDIO_RESOLUTION, | ||
79 | videoUUID: video.uuid, | ||
80 | isNewVideo: true | ||
81 | } | ||
82 | } else { | ||
83 | dataInput = { | ||
84 | type: 'optimize' as 'optimize', | ||
85 | videoUUID: video.uuid, | ||
86 | isNewVideo: true | ||
87 | } | ||
88 | } | ||
89 | |||
90 | return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) | ||
91 | } | ||
92 | |||
93 | function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | ||
94 | return isStreamingPlaylist(videoOrPlaylist) | ||
95 | ? videoOrPlaylist.Video | ||
96 | : videoOrPlaylist | ||
97 | } | ||
98 | |||
65 | export { | 99 | export { |
66 | VideoFetchType, | 100 | VideoFetchType, |
67 | VideoFetchByUrlType, | 101 | VideoFetchByUrlType, |
68 | fetchVideo, | 102 | fetchVideo, |
69 | getVideoWithAttributes, | 103 | getVideoWithAttributes, |
70 | fetchVideoByUrl | 104 | fetchVideoByUrl, |
105 | addOptimizeOrMergeAudioJob, | ||
106 | extractVideo | ||
71 | } | 107 | } |
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts index b25e44fcd..7cd76d708 100644 --- a/server/helpers/webtorrent.ts +++ b/server/helpers/webtorrent.ts | |||
@@ -13,8 +13,8 @@ import { WEBSERVER } from '@server/initializers/constants' | |||
13 | import * as parseTorrent from 'parse-torrent' | 13 | import * as parseTorrent from 'parse-torrent' |
14 | import * as magnetUtil from 'magnet-uri' | 14 | import * as magnetUtil from 'magnet-uri' |
15 | import { isArray } from '@server/helpers/custom-validators/misc' | 15 | import { isArray } from '@server/helpers/custom-validators/misc' |
16 | import { extractVideo } from '@server/lib/videos' | ||
17 | import { getTorrentFileName, getVideoFilePath } from '@server/lib/video-paths' | 16 | import { getTorrentFileName, getVideoFilePath } from '@server/lib/video-paths' |
17 | import { extractVideo } from '@server/helpers/video' | ||
18 | 18 | ||
19 | const createTorrentPromise = promisify2<string, any, any>(createTorrent) | 19 | const createTorrentPromise = promisify2<string, any, any>(createTorrent) |
20 | 20 | ||
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index a57d552df..f111be2ae 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts | |||
@@ -1,12 +1,11 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | import { isProdInstance, isTestInstance } from '../helpers/core-utils' | 2 | import { isProdInstance, isTestInstance } from '../helpers/core-utils' |
3 | import { UserModel } from '../models/account/user' | 3 | import { UserModel } from '../models/account/user' |
4 | import { ApplicationModel } from '../models/application/application' | 4 | import { getServerActor, ApplicationModel } from '../models/application/application' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { URL } from 'url' | 6 | import { URL } from 'url' |
7 | import { CONFIG, isEmailEnabled } from './config' | 7 | import { CONFIG, isEmailEnabled } from './config' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { getServerActor } from '../helpers/utils' | ||
10 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' | 9 | import { RecentlyAddedStrategy } from '../../shared/models/redundancy' |
11 | import { isArray } from '../helpers/custom-validators/misc' | 10 | import { isArray } from '../helpers/custom-validators/misc' |
12 | import { uniq } from 'lodash' | 11 | import { uniq } from 'lodash' |
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 8132ac135..c743dcf3f 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -19,7 +19,6 @@ import { AvatarModel } from '../../models/avatar/avatar' | |||
19 | import { ServerModel } from '../../models/server/server' | 19 | import { ServerModel } from '../../models/server/server' |
20 | import { VideoChannelModel } from '../../models/video/video-channel' | 20 | import { VideoChannelModel } from '../../models/video/video-channel' |
21 | import { JobQueue } from '../job-queue' | 21 | import { JobQueue } from '../job-queue' |
22 | import { getServerActor } from '../../helpers/utils' | ||
23 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' | 22 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' |
24 | import { sequelizeTypescript } from '../../initializers/database' | 23 | import { sequelizeTypescript } from '../../initializers/database' |
25 | import { | 24 | import { |
@@ -36,6 +35,7 @@ import { | |||
36 | MChannel | 35 | MChannel |
37 | } from '../../typings/models' | 36 | } from '../../typings/models' |
38 | import { extname } from 'path' | 37 | import { extname } from 'path' |
38 | import { getServerActor } from '@server/models/application/application' | ||
39 | 39 | ||
40 | // Set account keys, this could be long so process after the account creation and do not block the client | 40 | // Set account keys, this could be long so process after the account creation and do not block the client |
41 | function setAsyncActorKeys <T extends MActor> (actor: T) { | 41 | function setAsyncActorKeys <T extends MActor> (actor: T) { |
diff --git a/server/lib/activitypub/follow.ts b/server/lib/activitypub/follow.ts index a1c95504e..3b5ad47c9 100644 --- a/server/lib/activitypub/follow.ts +++ b/server/lib/activitypub/follow.ts | |||
@@ -3,8 +3,8 @@ import { CONFIG } from '../../initializers/config' | |||
3 | import { SERVER_ACTOR_NAME } from '../../initializers/constants' | 3 | import { SERVER_ACTOR_NAME } from '../../initializers/constants' |
4 | import { JobQueue } from '../job-queue' | 4 | import { JobQueue } from '../job-queue' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { getServerActor } from '../../helpers/utils' | ||
7 | import { ServerModel } from '../../models/server/server' | 6 | import { ServerModel } from '../../models/server/server' |
7 | import { getServerActor } from '@server/models/application/application' | ||
8 | 8 | ||
9 | async function autoFollowBackIfNeeded (actorFollow: MActorFollowActors) { | 9 | async function autoFollowBackIfNeeded (actorFollow: MActorFollowActors) { |
10 | if (!CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_BACK.ENABLED) return | 10 | if (!CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_BACK.ENABLED) return |
diff --git a/server/lib/activitypub/index.ts b/server/lib/activitypub/index.ts deleted file mode 100644 index d8c7d83b7..000000000 --- a/server/lib/activitypub/index.ts +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | export * from './process' | ||
2 | export * from './send' | ||
3 | export * from './actor' | ||
4 | export * from './share' | ||
5 | export * from './playlist' | ||
6 | export * from './videos' | ||
7 | export * from './video-comments' | ||
8 | export * from './video-rates' | ||
9 | export * from './url' | ||
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index db7fb8568..8f7828e41 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -7,11 +7,11 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |||
7 | import { sendAccept, sendReject } from '../send' | 7 | import { sendAccept, sendReject } from '../send' |
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { getServerActor } from '../../../helpers/utils' | ||
11 | import { CONFIG } from '../../../initializers/config' | 10 | import { CONFIG } from '../../../initializers/config' |
12 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | 11 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' |
13 | import { MActorFollowActors, MActorSignature } from '../../../typings/models' | 12 | import { MActorFollowActors, MActorSignature } from '../../../typings/models' |
14 | import { autoFollowBackIfNeeded } from '../follow' | 13 | import { autoFollowBackIfNeeded } from '../follow' |
14 | import { getServerActor } from '@server/models/application/application' | ||
15 | 15 | ||
16 | async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) { | 16 | async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) { |
17 | const { activity, byActor } = options | 17 | const { activity, byActor } = options |
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index e2fa061e8..0635c7b66 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -6,7 +6,6 @@ import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unic | |||
6 | import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience' | 6 | import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience' |
7 | import { logger } from '../../../helpers/logger' | 7 | import { logger } from '../../../helpers/logger' |
8 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 8 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
9 | import { getServerActor } from '../../../helpers/utils' | ||
10 | import { | 9 | import { |
11 | MActorLight, | 10 | MActorLight, |
12 | MCommentOwnerVideo, | 11 | MCommentOwnerVideo, |
@@ -17,6 +16,7 @@ import { | |||
17 | MVideoRedundancyStreamingPlaylistVideo | 16 | MVideoRedundancyStreamingPlaylistVideo |
18 | } from '../../../typings/models' | 17 | } from '../../../typings/models' |
19 | import { ContextType } from '@server/helpers/activitypub' | 18 | import { ContextType } from '@server/helpers/activitypub' |
19 | import { getServerActor } from '@server/models/application/application' | ||
20 | 20 | ||
21 | async function sendCreateVideo (video: MVideoAP, t: Transaction) { | 21 | async function sendCreateVideo (video: MVideoAP, t: Transaction) { |
22 | if (!video.hasPrivacyForFederation()) return undefined | 22 | if (!video.hasPrivacyForFederation()) return undefined |
diff --git a/server/lib/activitypub/send/send-delete.ts b/server/lib/activitypub/send/send-delete.ts index 3225ebf32..fd3f06dec 100644 --- a/server/lib/activitypub/send/send-delete.ts +++ b/server/lib/activitypub/send/send-delete.ts | |||
@@ -7,9 +7,9 @@ import { getDeleteActivityPubUrl } from '../url' | |||
7 | import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' | 7 | import { broadcastToActors, broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' |
8 | import { audiencify, getActorsInvolvedInVideo, getVideoCommentAudience } from '../audience' | 8 | import { audiencify, getActorsInvolvedInVideo, getVideoCommentAudience } from '../audience' |
9 | import { logger } from '../../../helpers/logger' | 9 | import { logger } from '../../../helpers/logger' |
10 | import { getServerActor } from '../../../helpers/utils' | ||
11 | import { MCommentOwnerVideoReply, MVideoAccountLight, MVideoPlaylistFullSummary } from '../../../typings/models/video' | 10 | import { MCommentOwnerVideoReply, MVideoAccountLight, MVideoPlaylistFullSummary } from '../../../typings/models/video' |
12 | import { MActorUrl } from '../../../typings/models' | 11 | import { MActorUrl } from '../../../typings/models' |
12 | import { getServerActor } from '@server/models/application/application' | ||
13 | 13 | ||
14 | async function sendDeleteVideo (video: MVideoAccountLight, transaction: Transaction) { | 14 | async function sendDeleteVideo (video: MVideoAccountLight, transaction: Transaction) { |
15 | logger.info('Creating job to broadcast delete of video %s.', video.url) | 15 | logger.info('Creating job to broadcast delete of video %s.', video.url) |
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 2b01ca5e7..7a4cf3f56 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -9,7 +9,6 @@ import { broadcastToFollowers, sendVideoRelatedActivity } from './utils' | |||
9 | import { audiencify, getActorsInvolvedInVideo, getAudience } from '../audience' | 9 | import { audiencify, getActorsInvolvedInVideo, getAudience } from '../audience' |
10 | import { logger } from '../../../helpers/logger' | 10 | import { logger } from '../../../helpers/logger' |
11 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 11 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
12 | import { getServerActor } from '../../../helpers/utils' | ||
13 | import { | 12 | import { |
14 | MAccountDefault, | 13 | MAccountDefault, |
15 | MActor, | 14 | MActor, |
@@ -20,6 +19,7 @@ import { | |||
20 | MVideoPlaylistFull, | 19 | MVideoPlaylistFull, |
21 | MVideoRedundancyVideo | 20 | MVideoRedundancyVideo |
22 | } from '../../../typings/models' | 21 | } from '../../../typings/models' |
22 | import { getServerActor } from '@server/models/application/application' | ||
23 | 23 | ||
24 | async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction, overrodeByActor?: MActor) { | 24 | async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction, overrodeByActor?: MActor) { |
25 | const video = videoArg as MVideoAP | 25 | const video = videoArg as MVideoAP |
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts index 6fd53d71b..0dfcc51be 100644 --- a/server/lib/activitypub/send/utils.ts +++ b/server/lib/activitypub/send/utils.ts | |||
@@ -5,10 +5,10 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
6 | import { JobQueue } from '../../job-queue' | 6 | import { JobQueue } from '../../job-queue' |
7 | import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience' | 7 | import { getActorsInvolvedInVideo, getAudienceFromFollowersOf, getRemoteVideoAudience } from '../audience' |
8 | import { getServerActor } from '../../../helpers/utils' | ||
9 | import { afterCommitIfTransaction } from '../../../helpers/database-utils' | 8 | import { afterCommitIfTransaction } from '../../../helpers/database-utils' |
10 | import { MActor, MActorId, MActorLight, MActorWithInboxes, MVideoAccountLight, MVideoId, MVideoImmutable } from '../../../typings/models' | 9 | import { MActor, MActorId, MActorLight, MActorWithInboxes, MVideoAccountLight, MVideoId, MVideoImmutable } from '../../../typings/models' |
11 | import { ContextType } from '@server/helpers/activitypub' | 10 | import { ContextType } from '@server/helpers/activitypub' |
11 | import { getServerActor } from '@server/models/application/application' | ||
12 | 12 | ||
13 | async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { | 13 | async function sendVideoRelatedActivity (activityBuilder: (audience: ActivityAudience) => Activity, options: { |
14 | byActor: MActorLight | 14 | byActor: MActorLight |
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index a7c645062..d2cbc59a8 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { getServerActor } from '../../helpers/utils' | ||
3 | import { VideoShareModel } from '../../models/video/video-share' | 2 | import { VideoShareModel } from '../../models/video/video-share' |
4 | import { sendUndoAnnounce, sendVideoAnnounce } from './send' | 3 | import { sendUndoAnnounce, sendVideoAnnounce } from './send' |
5 | import { getVideoAnnounceActivityPubUrl } from './url' | 4 | import { getVideoAnnounceActivityPubUrl } from './url' |
@@ -10,6 +9,7 @@ import { logger } from '../../helpers/logger' | |||
10 | import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' | 9 | import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' |
11 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' | 10 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' |
12 | import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models/video' | 11 | import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models/video' |
12 | import { getServerActor } from '@server/models/application/application' | ||
13 | 13 | ||
14 | async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) { | 14 | async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) { |
15 | if (!video.hasPrivacyForFederation()) return undefined | 15 | if (!video.hasPrivacyForFederation()) return undefined |
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 62f589272..7d16bd390 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -6,7 +6,7 @@ import { | |||
6 | ActivityHashTagObject, | 6 | ActivityHashTagObject, |
7 | ActivityMagnetUrlObject, | 7 | ActivityMagnetUrlObject, |
8 | ActivityPlaylistSegmentHashesObject, | 8 | ActivityPlaylistSegmentHashesObject, |
9 | ActivityPlaylistUrlObject, | 9 | ActivityPlaylistUrlObject, ActivitypubHttpFetcherPayload, |
10 | ActivityTagObject, | 10 | ActivityTagObject, |
11 | ActivityUrlObject, | 11 | ActivityUrlObject, |
12 | ActivityVideoUrlObject, | 12 | ActivityVideoUrlObject, |
@@ -38,7 +38,6 @@ import { sendCreateVideo, sendUpdateVideo } from './send' | |||
38 | import { isArray } from '../../helpers/custom-validators/misc' | 38 | import { isArray } from '../../helpers/custom-validators/misc' |
39 | import { VideoCaptionModel } from '../../models/video/video-caption' | 39 | import { VideoCaptionModel } from '../../models/video/video-caption' |
40 | import { JobQueue } from '../job-queue' | 40 | import { JobQueue } from '../job-queue' |
41 | import { ActivitypubHttpFetcherPayload } from '../job-queue/handlers/activitypub-http-fetcher' | ||
42 | import { createRates } from './video-rates' | 41 | import { createRates } from './video-rates' |
43 | import { addVideoShares, shareVideoByServerAndChannel } from './share' | 42 | import { addVideoShares, shareVideoByServerAndChannel } from './share' |
44 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' | 43 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' |
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 3de45dd19..282d834a2 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { sendUpdateActor } from './activitypub/send' | 2 | import { sendUpdateActor } from './activitypub/send' |
3 | import { AVATARS_SIZE, LRU_CACHE, QUEUE_CONCURRENCY } from '../initializers/constants' | 3 | import { AVATARS_SIZE, LRU_CACHE, QUEUE_CONCURRENCY } from '../initializers/constants' |
4 | import { updateActorAvatarInstance } from './activitypub' | 4 | import { updateActorAvatarInstance } from './activitypub/actor' |
5 | import { processImage } from '../helpers/image-utils' | 5 | import { processImage } from '../helpers/image-utils' |
6 | import { extname, join } from 'path' | 6 | import { extname, join } from 'path' |
7 | import { retryTransactionWrapper } from '../helpers/database-utils' | 7 | import { retryTransactionWrapper } from '../helpers/database-utils' |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 5a99edc7f..45d57fd28 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -3,7 +3,6 @@ import { isTestInstance } from '../helpers/core-utils' | |||
3 | import { bunyanLogger, logger } from '../helpers/logger' | 3 | import { bunyanLogger, logger } from '../helpers/logger' |
4 | import { CONFIG, isEmailEnabled } from '../initializers/config' | 4 | import { CONFIG, isEmailEnabled } from '../initializers/config' |
5 | import { JobQueue } from './job-queue' | 5 | import { JobQueue } from './job-queue' |
6 | import { EmailPayload } from './job-queue/handlers/email' | ||
7 | import { readFileSync } from 'fs-extra' | 6 | import { readFileSync } from 'fs-extra' |
8 | import { WEBSERVER } from '../initializers/constants' | 7 | import { WEBSERVER } from '../initializers/constants' |
9 | import { | 8 | import { |
@@ -16,15 +15,7 @@ import { | |||
16 | } from '../typings/models/video' | 15 | } from '../typings/models/video' |
17 | import { MActorFollowActors, MActorFollowFull, MUser } from '../typings/models' | 16 | import { MActorFollowActors, MActorFollowFull, MUser } from '../typings/models' |
18 | import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import' | 17 | import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import' |
19 | 18 | import { EmailPayload } from '@shared/models' | |
20 | type SendEmailOptions = { | ||
21 | to: string[] | ||
22 | subject: string | ||
23 | text: string | ||
24 | |||
25 | fromDisplayName?: string | ||
26 | replyTo?: string | ||
27 | } | ||
28 | 19 | ||
29 | class Emailer { | 20 | class Emailer { |
30 | 21 | ||
@@ -507,6 +498,5 @@ class Emailer { | |||
507 | // --------------------------------------------------------------------------- | 498 | // --------------------------------------------------------------------------- |
508 | 499 | ||
509 | export { | 500 | export { |
510 | Emailer, | 501 | Emailer |
511 | SendEmailOptions | ||
512 | } | 502 | } |
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index e467c5b1b..7034c10d0 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts | |||
@@ -11,14 +11,7 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
11 | import { Notifier } from '../../notifier' | 11 | import { Notifier } from '../../notifier' |
12 | import { sequelizeTypescript } from '../../../initializers/database' | 12 | import { sequelizeTypescript } from '../../../initializers/database' |
13 | import { MActor, MActorFollowActors, MActorFull } from '../../../typings/models' | 13 | import { MActor, MActorFollowActors, MActorFull } from '../../../typings/models' |
14 | 14 | import { ActivitypubFollowPayload } from '@shared/models' | |
15 | export type ActivitypubFollowPayload = { | ||
16 | followerActorId: number | ||
17 | name: string | ||
18 | host: string | ||
19 | isAutoFollow?: boolean | ||
20 | assertIsChannel?: boolean | ||
21 | } | ||
22 | 15 | ||
23 | async function processActivityPubFollow (job: Bull.Job) { | 16 | async function processActivityPubFollow (job: Bull.Job) { |
24 | const payload = job.data as ActivitypubFollowPayload | 17 | const payload = job.data as ActivitypubFollowPayload |
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index 7d9dd61e9..e4d3dbbff 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts | |||
@@ -5,14 +5,7 @@ import { doRequest } from '../../../helpers/requests' | |||
5 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 5 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
6 | import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' | 6 | import { BROADCAST_CONCURRENCY, JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' |
7 | import { ActorFollowScoreCache } from '../../files-cache' | 7 | import { ActorFollowScoreCache } from '../../files-cache' |
8 | import { ContextType } from '@server/helpers/activitypub' | 8 | import { ActivitypubHttpBroadcastPayload } from '@shared/models' |
9 | |||
10 | export type ActivitypubHttpBroadcastPayload = { | ||
11 | uris: string[] | ||
12 | signatureActorId?: number | ||
13 | body: any | ||
14 | contextType?: ContextType | ||
15 | } | ||
16 | 9 | ||
17 | async function processActivityPubHttpBroadcast (job: Bull.Job) { | 10 | async function processActivityPubHttpBroadcast (job: Bull.Job) { |
18 | logger.info('Processing ActivityPub broadcast in job %d.', job.id) | 11 | logger.info('Processing ActivityPub broadcast in job %d.', job.id) |
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index 0182c5169..524aadc27 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts | |||
@@ -5,22 +5,15 @@ import { processActivities } from '../../activitypub/process' | |||
5 | import { addVideoComments } from '../../activitypub/video-comments' | 5 | import { addVideoComments } from '../../activitypub/video-comments' |
6 | import { crawlCollectionPage } from '../../activitypub/crawl' | 6 | import { crawlCollectionPage } from '../../activitypub/crawl' |
7 | import { VideoModel } from '../../../models/video/video' | 7 | import { VideoModel } from '../../../models/video/video' |
8 | import { addVideoShares, createRates } from '../../activitypub' | 8 | import { addVideoShares } from '../../activitypub/share' |
9 | import { createRates } from '../../activitypub/video-rates' | ||
9 | import { createAccountPlaylists } from '../../activitypub/playlist' | 10 | import { createAccountPlaylists } from '../../activitypub/playlist' |
10 | import { AccountModel } from '../../../models/account/account' | 11 | import { AccountModel } from '../../../models/account/account' |
11 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 12 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
12 | import { VideoShareModel } from '../../../models/video/video-share' | 13 | import { VideoShareModel } from '../../../models/video/video-share' |
13 | import { VideoCommentModel } from '../../../models/video/video-comment' | 14 | import { VideoCommentModel } from '../../../models/video/video-comment' |
14 | import { MAccountDefault, MVideoFullLight } from '../../../typings/models' | 15 | import { MAccountDefault, MVideoFullLight } from '../../../typings/models' |
15 | 16 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' | |
16 | type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists' | ||
17 | |||
18 | export type ActivitypubHttpFetcherPayload = { | ||
19 | uri: string | ||
20 | type: FetchType | ||
21 | videoId?: number | ||
22 | accountId?: number | ||
23 | } | ||
24 | 17 | ||
25 | async function processActivityPubHttpFetcher (job: Bull.Job) { | 18 | async function processActivityPubHttpFetcher (job: Bull.Job) { |
26 | logger.info('Processing ActivityPub fetcher in job %d.', job.id) | 19 | logger.info('Processing ActivityPub fetcher in job %d.', job.id) |
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts index 6b71e2891..b65eeb677 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts | |||
@@ -4,14 +4,7 @@ import { doRequest } from '../../../helpers/requests' | |||
4 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 4 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
5 | import { JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' | 5 | import { JOB_REQUEST_TIMEOUT } from '../../../initializers/constants' |
6 | import { ActorFollowScoreCache } from '../../files-cache' | 6 | import { ActorFollowScoreCache } from '../../files-cache' |
7 | import { ContextType } from '@server/helpers/activitypub' | 7 | import { ActivitypubHttpUnicastPayload } from '@shared/models' |
8 | |||
9 | export type ActivitypubHttpUnicastPayload = { | ||
10 | uri: string | ||
11 | signatureActorId?: number | ||
12 | body: any | ||
13 | contextType?: ContextType | ||
14 | } | ||
15 | 8 | ||
16 | async function processActivityPubHttpUnicast (job: Bull.Job) { | 9 | async function processActivityPubHttpUnicast (job: Bull.Job) { |
17 | logger.info('Processing ActivityPub unicast in job %d.', job.id) | 10 | logger.info('Processing ActivityPub unicast in job %d.', job.id) |
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts index 4d6c38cfa..666e56868 100644 --- a/server/lib/job-queue/handlers/activitypub-refresher.ts +++ b/server/lib/job-queue/handlers/activitypub-refresher.ts | |||
@@ -1,14 +1,12 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { fetchVideoByUrl } from '../../../helpers/video' | 3 | import { fetchVideoByUrl } from '../../../helpers/video' |
4 | import { refreshActorIfNeeded, refreshVideoIfNeeded, refreshVideoPlaylistIfNeeded } from '../../activitypub' | 4 | import { refreshActorIfNeeded } from '../../activitypub/actor' |
5 | import { refreshVideoIfNeeded } from '../../activitypub/videos' | ||
5 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
6 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 7 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
7 | 8 | import { RefreshPayload } from '@shared/models' | |
8 | export type RefreshPayload = { | 9 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlist' |
9 | type: 'video' | 'video-playlist' | 'actor' | ||
10 | url: string | ||
11 | } | ||
12 | 10 | ||
13 | async function refreshAPObject (job: Bull.Job) { | 11 | async function refreshAPObject (job: Bull.Job) { |
14 | const payload = job.data as RefreshPayload | 12 | const payload = job.data as RefreshPayload |
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts index 62701222c..3157731e2 100644 --- a/server/lib/job-queue/handlers/email.ts +++ b/server/lib/job-queue/handlers/email.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { Emailer, SendEmailOptions } from '../../emailer' | 3 | import { Emailer } from '../../emailer' |
4 | 4 | import { EmailPayload } from '@shared/models' | |
5 | export type EmailPayload = SendEmailOptions | ||
6 | 5 | ||
7 | async function processEmail (job: Bull.Job) { | 6 | async function processEmail (job: Bull.Job) { |
8 | const payload = job.data as EmailPayload | 7 | const payload = job.data as EmailPayload |
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 258ffabee..437ea06fc 100644 --- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts +++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { buildSignedActivity, ContextType } from '../../../../helpers/activitypub' | 1 | import { buildSignedActivity, ContextType } from '../../../../helpers/activitypub' |
2 | import { getServerActor } from '../../../../helpers/utils' | ||
3 | import { ActorModel } from '../../../../models/activitypub/actor' | 2 | import { ActorModel } from '../../../../models/activitypub/actor' |
4 | import { sha256 } from '../../../../helpers/core-utils' | ||
5 | import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants' | 3 | import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants' |
6 | import { MActor } from '../../../../typings/models' | 4 | import { MActor } from '../../../../typings/models' |
5 | import { getServerActor } from '@server/models/application/application' | ||
6 | import { buildDigest } from '@server/helpers/peertube-crypto' | ||
7 | 7 | ||
8 | type Payload = { body: any, contextType?: ContextType, signatureActorId?: number } | 8 | type Payload = { body: any, contextType?: ContextType, signatureActorId?: number } |
9 | 9 | ||
@@ -48,14 +48,7 @@ function buildGlobalHeaders (body: any) { | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | function buildDigest (body: any) { | ||
52 | const rawBody = typeof body === 'string' ? body : JSON.stringify(body) | ||
53 | |||
54 | return 'SHA-256=' + sha256(rawBody, 'base64') | ||
55 | } | ||
56 | |||
57 | export { | 51 | export { |
58 | buildDigest, | ||
59 | buildGlobalHeaders, | 52 | buildGlobalHeaders, |
60 | computeBody, | 53 | computeBody, |
61 | buildSignedRequestOptions | 54 | buildSignedRequestOptions |
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index be9e7d181..ae11f1de3 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts | |||
@@ -9,11 +9,7 @@ import { extname } from 'path' | |||
9 | import { MVideoFile, MVideoWithFile } from '@server/typings/models' | 9 | import { MVideoFile, MVideoWithFile } from '@server/typings/models' |
10 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 10 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
11 | import { getVideoFilePath } from '@server/lib/video-paths' | 11 | import { getVideoFilePath } from '@server/lib/video-paths' |
12 | 12 | import { VideoFileImportPayload } from '@shared/models' | |
13 | export type VideoFileImportPayload = { | ||
14 | videoUUID: string | ||
15 | filePath: string | ||
16 | } | ||
17 | 13 | ||
18 | async function processVideoFileImport (job: Bull.Job) { | 14 | async function processVideoFileImport (job: Bull.Job) { |
19 | const payload = job.data as VideoFileImportPayload | 15 | const payload = job.data as VideoFileImportPayload |
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 6cdae5b03..ad549c6fc 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -7,8 +7,8 @@ import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } fro | |||
7 | import { extname } from 'path' | 7 | import { extname } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { VIDEO_IMPORT_TIMEOUT } from '../../../initializers/constants' | 9 | import { VIDEO_IMPORT_TIMEOUT } from '../../../initializers/constants' |
10 | import { VideoState } from '../../../../shared' | 10 | import { VideoImportPayload, VideoImportTorrentPayload, VideoImportYoutubeDLPayload, VideoState } from '../../../../shared' |
11 | import { federateVideoIfNeeded } from '../../activitypub' | 11 | import { federateVideoIfNeeded } from '../../activitypub/videos' |
12 | import { VideoModel } from '../../../models/video/video' | 12 | import { VideoModel } from '../../../models/video/video' |
13 | import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 13 | import { createTorrentAndSetInfoHash, downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
14 | import { getSecureTorrentName } from '../../../helpers/utils' | 14 | import { getSecureTorrentName } from '../../../helpers/utils' |
@@ -21,24 +21,7 @@ import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type' | |||
21 | import { MThumbnail } from '../../../typings/models/video/thumbnail' | 21 | import { MThumbnail } from '../../../typings/models/video/thumbnail' |
22 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/typings/models/video/video-import' | 22 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/typings/models/video/video-import' |
23 | import { getVideoFilePath } from '@server/lib/video-paths' | 23 | import { getVideoFilePath } from '@server/lib/video-paths' |
24 | import { addOptimizeOrMergeAudioJob } from '@server/lib/videos' | 24 | import { addOptimizeOrMergeAudioJob } from '@server/helpers/video' |
25 | |||
26 | type VideoImportYoutubeDLPayload = { | ||
27 | type: 'youtube-dl' | ||
28 | videoImportId: number | ||
29 | |||
30 | generateThumbnail: boolean | ||
31 | generatePreview: boolean | ||
32 | |||
33 | fileExt?: string | ||
34 | } | ||
35 | |||
36 | type VideoImportTorrentPayload = { | ||
37 | type: 'magnet-uri' | 'torrent-file' | ||
38 | videoImportId: number | ||
39 | } | ||
40 | |||
41 | export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload | ||
42 | 25 | ||
43 | async function processVideoImport (job: Bull.Job) { | 26 | async function processVideoImport (job: Bull.Job) { |
44 | const payload = job.data as VideoImportPayload | 27 | const payload = job.data as VideoImportPayload |
diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/lib/job-queue/handlers/video-redundancy.ts index 319d7090e..6296dab05 100644 --- a/server/lib/job-queue/handlers/video-redundancy.ts +++ b/server/lib/job-queue/handlers/video-redundancy.ts | |||
@@ -1,10 +1,7 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' | 3 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' |
4 | 4 | import { VideoRedundancyPayload } from '@shared/models' | |
5 | export type VideoRedundancyPayload = { | ||
6 | videoId: number | ||
7 | } | ||
8 | 5 | ||
9 | async function processVideoRedundancy (job: Bull.Job) { | 6 | async function processVideoRedundancy (job: Bull.Job) { |
10 | const payload = job.data as VideoRedundancyPayload | 7 | const payload = job.data as VideoRedundancyPayload |
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index c020057c9..46add57d4 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -1,9 +1,14 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { VideoResolution } from '../../../../shared' | 2 | import { |
3 | MergeAudioTranscodingPayload, | ||
4 | NewResolutionTranscodingPayload, | ||
5 | OptimizeTranscodingPayload, | ||
6 | VideoTranscodingPayload | ||
7 | } from '../../../../shared' | ||
3 | import { logger } from '../../../helpers/logger' | 8 | import { logger } from '../../../helpers/logger' |
4 | import { VideoModel } from '../../../models/video/video' | 9 | import { VideoModel } from '../../../models/video/video' |
5 | import { JobQueue } from '../job-queue' | 10 | import { JobQueue } from '../job-queue' |
6 | import { federateVideoIfNeeded } from '../../activitypub' | 11 | import { federateVideoIfNeeded } from '../../activitypub/videos' |
7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 12 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
8 | import { sequelizeTypescript } from '../../../initializers' | 13 | import { sequelizeTypescript } from '../../../initializers' |
9 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 14 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
@@ -12,39 +17,6 @@ import { Notifier } from '../../notifier' | |||
12 | import { CONFIG } from '../../../initializers/config' | 17 | import { CONFIG } from '../../../initializers/config' |
13 | import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/typings/models' | 18 | import { MVideoFullLight, MVideoUUID, MVideoWithFile } from '@server/typings/models' |
14 | 19 | ||
15 | interface BaseTranscodingPayload { | ||
16 | videoUUID: string | ||
17 | isNewVideo?: boolean | ||
18 | } | ||
19 | |||
20 | interface HLSTranscodingPayload extends BaseTranscodingPayload { | ||
21 | type: 'hls' | ||
22 | isPortraitMode?: boolean | ||
23 | resolution: VideoResolution | ||
24 | copyCodecs: boolean | ||
25 | } | ||
26 | |||
27 | interface NewResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
28 | type: 'new-resolution' | ||
29 | isPortraitMode?: boolean | ||
30 | resolution: VideoResolution | ||
31 | } | ||
32 | |||
33 | interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
34 | type: 'merge-audio' | ||
35 | resolution: VideoResolution | ||
36 | } | ||
37 | |||
38 | interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
39 | type: 'optimize' | ||
40 | } | ||
41 | |||
42 | export type VideoTranscodingPayload = | ||
43 | HLSTranscodingPayload | ||
44 | | NewResolutionTranscodingPayload | ||
45 | | OptimizeTranscodingPayload | ||
46 | | MergeAudioTranscodingPayload | ||
47 | |||
48 | async function processVideoTranscoding (job: Bull.Job) { | 20 | async function processVideoTranscoding (job: Bull.Job) { |
49 | const payload = job.data as VideoTranscodingPayload | 21 | const payload = job.data as VideoTranscodingPayload |
50 | logger.info('Processing video file in job %d.', job.id) | 22 | logger.info('Processing video file in job %d.', job.id) |
diff --git a/server/lib/job-queue/handlers/video-views.ts b/server/lib/job-queue/handlers/video-views.ts index 2258cd029..7211df237 100644 --- a/server/lib/job-queue/handlers/video-views.ts +++ b/server/lib/job-queue/handlers/video-views.ts | |||
@@ -3,7 +3,7 @@ import { logger } from '../../../helpers/logger' | |||
3 | import { VideoModel } from '../../../models/video/video' | 3 | import { VideoModel } from '../../../models/video/video' |
4 | import { VideoViewModel } from '../../../models/video/video-views' | 4 | import { VideoViewModel } from '../../../models/video/video-views' |
5 | import { isTestInstance } from '../../../helpers/core-utils' | 5 | import { isTestInstance } from '../../../helpers/core-utils' |
6 | import { federateVideoIfNeeded } from '../../activitypub' | 6 | import { federateVideoIfNeeded } from '../../activitypub/videos' |
7 | 7 | ||
8 | async function processVideosViews () { | 8 | async function processVideosViews () { |
9 | const lastHour = new Date() | 9 | const lastHour = new Date() |
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 14acace7d..d8d64caaf 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -1,19 +1,25 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { JobState, JobType } from '../../../shared/models' | 2 | import { |
3 | ActivitypubFollowPayload, | ||
4 | ActivitypubHttpBroadcastPayload, | ||
5 | ActivitypubHttpFetcherPayload, ActivitypubHttpUnicastPayload, EmailPayload, | ||
6 | JobState, | ||
7 | JobType, RefreshPayload, VideoFileImportPayload, VideoImportPayload, VideoRedundancyPayload, VideoTranscodingPayload | ||
8 | } from '../../../shared/models' | ||
3 | import { logger } from '../../helpers/logger' | 9 | import { logger } from '../../helpers/logger' |
4 | import { Redis } from '../redis' | 10 | import { Redis } from '../redis' |
5 | import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants' | 11 | import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers/constants' |
6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' | 12 | import { processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' |
7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 13 | import { processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' | 14 | import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' |
9 | import { EmailPayload, processEmail } from './handlers/email' | 15 | import { processEmail } from './handlers/email' |
10 | import { processVideoTranscoding, VideoTranscodingPayload } from './handlers/video-transcoding' | 16 | import { processVideoTranscoding} from './handlers/video-transcoding' |
11 | import { ActivitypubFollowPayload, processActivityPubFollow } from './handlers/activitypub-follow' | 17 | import { processActivityPubFollow } from './handlers/activitypub-follow' |
12 | import { processVideoImport, VideoImportPayload } from './handlers/video-import' | 18 | import { processVideoImport} from './handlers/video-import' |
13 | import { processVideosViews } from './handlers/video-views' | 19 | import { processVideosViews } from './handlers/video-views' |
14 | import { refreshAPObject, RefreshPayload } from './handlers/activitypub-refresher' | 20 | import { refreshAPObject} from './handlers/activitypub-refresher' |
15 | import { processVideoFileImport, VideoFileImportPayload } from './handlers/video-file-import' | 21 | import { processVideoFileImport} from './handlers/video-file-import' |
16 | import { processVideoRedundancy, VideoRedundancyPayload } from '@server/lib/job-queue/handlers/video-redundancy' | 22 | import { processVideoRedundancy} from '@server/lib/job-queue/handlers/video-redundancy' |
17 | 23 | ||
18 | type CreateJobArgument = | 24 | type CreateJobArgument = |
19 | { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | | 25 | { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | |
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 63197eee1..710c2d30f 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts | |||
@@ -26,7 +26,7 @@ import { | |||
26 | import { MAccountDefault, MActorFollowFull } from '../typings/models' | 26 | import { MAccountDefault, MActorFollowFull } from '../typings/models' |
27 | import { MVideoImportVideo } from '@server/typings/models/video/video-import' | 27 | import { MVideoImportVideo } from '@server/typings/models/video/video-import' |
28 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | 28 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' |
29 | import { getServerActor } from '@server/helpers/utils' | 29 | import { getServerActor } from '@server/models/application/application' |
30 | 30 | ||
31 | class Notifier { | 31 | class Notifier { |
32 | 32 | ||
diff --git a/server/lib/redundancy.ts b/server/lib/redundancy.ts index aa0e37478..361b401a5 100644 --- a/server/lib/redundancy.ts +++ b/server/lib/redundancy.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' | 1 | import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' |
2 | import { sendUndoCacheFile } from './activitypub/send' | 2 | import { sendUndoCacheFile } from './activitypub/send' |
3 | import { Transaction } from 'sequelize' | 3 | import { Transaction } from 'sequelize' |
4 | import { getServerActor } from '../helpers/utils' | ||
5 | import { MActorSignature, MVideoRedundancyVideo } from '@server/typings/models' | 4 | import { MActorSignature, MVideoRedundancyVideo } from '@server/typings/models' |
6 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
7 | import { logger } from '@server/helpers/logger' | 6 | import { logger } from '@server/helpers/logger' |
8 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | 7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' |
9 | import { Activity } from '@shared/models' | 8 | import { Activity } from '@shared/models' |
9 | import { getServerActor } from '@server/models/application/application' | ||
10 | 10 | ||
11 | async function removeVideoRedundancy (videoRedundancy: MVideoRedundancyVideo, t?: Transaction) { | 11 | async function removeVideoRedundancy (videoRedundancy: MVideoRedundancyVideo, t?: Transaction) { |
12 | const serverActor = await getServerActor() | 12 | const serverActor = await getServerActor() |
diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index a1f5e4a91..e852c7fc6 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts | |||
@@ -6,7 +6,7 @@ import { chunk } from 'lodash' | |||
6 | import { doRequest } from '@server/helpers/requests' | 6 | import { doRequest } from '@server/helpers/requests' |
7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | 7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' |
8 | import { JobQueue } from '@server/lib/job-queue' | 8 | import { JobQueue } from '@server/lib/job-queue' |
9 | import { getServerActor } from '@server/helpers/utils' | 9 | import { getServerActor } from '@server/models/application/application' |
10 | 10 | ||
11 | export class AutoFollowIndexInstances extends AbstractScheduler { | 11 | export class AutoFollowIndexInstances extends AbstractScheduler { |
12 | 12 | ||
diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index 956780a77..d32c1c068 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts | |||
@@ -2,7 +2,7 @@ import { logger } from '../../helpers/logger' | |||
2 | import { AbstractScheduler } from './abstract-scheduler' | 2 | import { AbstractScheduler } from './abstract-scheduler' |
3 | import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' | 3 | import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update' |
4 | import { retryTransactionWrapper } from '../../helpers/database-utils' | 4 | import { retryTransactionWrapper } from '../../helpers/database-utils' |
5 | import { federateVideoIfNeeded } from '../activitypub' | 5 | import { federateVideoIfNeeded } from '../activitypub/videos' |
6 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' | 6 | import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants' |
7 | import { Notifier } from '../notifier' | 7 | import { Notifier } from '../notifier' |
8 | import { sequelizeTypescript } from '../../initializers/database' | 8 | import { sequelizeTypescript } from '../../initializers/database' |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index e33a4133a..8da9d52b5 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -6,11 +6,10 @@ import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | |||
6 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' | 6 | import { downloadWebTorrentVideo, generateMagnetUri } from '../../helpers/webtorrent' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { move } from 'fs-extra' | 8 | import { move } from 'fs-extra' |
9 | import { getServerActor } from '../../helpers/utils' | ||
10 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' | 9 | import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send' |
11 | import { getVideoCacheFileActivityPubUrl, getVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' | 10 | import { getVideoCacheFileActivityPubUrl, getVideoCacheStreamingPlaylistActivityPubUrl } from '../activitypub/url' |
12 | import { removeVideoRedundancy } from '../redundancy' | 11 | import { removeVideoRedundancy } from '../redundancy' |
13 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub' | 12 | import { getOrCreateVideoAndAccountAndChannel } from '../activitypub/videos' |
14 | import { downloadPlaylistSegments } from '../hls' | 13 | import { downloadPlaylistSegments } from '../hls' |
15 | import { CONFIG } from '../../initializers/config' | 14 | import { CONFIG } from '../../initializers/config' |
16 | import { | 15 | import { |
@@ -26,6 +25,7 @@ import { | |||
26 | } from '@server/typings/models' | 25 | } from '@server/typings/models' |
27 | import { getVideoFilename } from '../video-paths' | 26 | import { getVideoFilename } from '../video-paths' |
28 | import { VideoModel } from '@server/models/video/video' | 27 | import { VideoModel } from '@server/models/video/video' |
28 | import { getServerActor } from '@server/models/application/application' | ||
29 | 29 | ||
30 | type CandidateToDuplicate = { | 30 | type CandidateToDuplicate = { |
31 | redundancy: VideosRedundancyStrategy | 31 | redundancy: VideosRedundancyStrategy |
diff --git a/server/lib/video-comment.ts b/server/lib/video-comment.ts index fe83d23e7..516c912a9 100644 --- a/server/lib/video-comment.ts +++ b/server/lib/video-comment.ts | |||
@@ -2,7 +2,7 @@ import * as Sequelize from 'sequelize' | |||
2 | import { ResultList } from '../../shared/models' | 2 | import { ResultList } from '../../shared/models' |
3 | import { VideoCommentThreadTree } from '../../shared/models/videos/video-comment.model' | 3 | import { VideoCommentThreadTree } from '../../shared/models/videos/video-comment.model' |
4 | import { VideoCommentModel } from '../models/video/video-comment' | 4 | import { VideoCommentModel } from '../models/video/video-comment' |
5 | import { getVideoCommentActivityPubUrl } from './activitypub' | 5 | import { getVideoCommentActivityPubUrl } from './activitypub/url' |
6 | import { sendCreateVideoComment } from './activitypub/send' | 6 | import { sendCreateVideoComment } from './activitypub/send' |
7 | import { MAccountDefault, MComment, MCommentOwnerVideoReply, MVideoFullLight } from '../typings/models' | 7 | import { MAccountDefault, MComment, MCommentOwnerVideoReply, MVideoFullLight } from '../typings/models' |
8 | 8 | ||
diff --git a/server/lib/video-paths.ts b/server/lib/video-paths.ts index fe0a004e4..05aaca8af 100644 --- a/server/lib/video-paths.ts +++ b/server/lib/video-paths.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/typings/models' | 1 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/typings/models' |
2 | import { extractVideo } from './videos' | ||
3 | import { join } from 'path' | 2 | import { join } from 'path' |
4 | import { CONFIG } from '@server/initializers/config' | 3 | import { CONFIG } from '@server/initializers/config' |
5 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' | 4 | import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants' |
5 | import { extractVideo } from '@server/helpers/video' | ||
6 | 6 | ||
7 | // ################## Video file name ################## | 7 | // ################## Video file name ################## |
8 | 8 | ||
diff --git a/server/lib/video-playlist.ts b/server/lib/video-playlist.ts index 29b70cfda..75fbd6896 100644 --- a/server/lib/video-playlist.ts +++ b/server/lib/video-playlist.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { VideoPlaylistModel } from '../models/video/video-playlist' | 2 | import { VideoPlaylistModel } from '../models/video/video-playlist' |
3 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' | 3 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' |
4 | import { getVideoPlaylistActivityPubUrl } from './activitypub' | 4 | import { getVideoPlaylistActivityPubUrl } from './activitypub/url' |
5 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' | 5 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' |
6 | import { MAccount } from '../typings/models' | 6 | import { MAccount } from '../typings/models' |
7 | import { MVideoPlaylistOwner } from '../typings/models/video/video-playlist' | 7 | import { MVideoPlaylistOwner } from '../typings/models/video/video-playlist' |
diff --git a/server/lib/videos.ts b/server/lib/videos.ts deleted file mode 100644 index 96bdd42e9..000000000 --- a/server/lib/videos.ts +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile } from '@server/typings/models' | ||
2 | import { VideoTranscodingPayload } from '@server/lib/job-queue/handlers/video-transcoding' | ||
3 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | ||
4 | import { JobQueue } from '@server/lib/job-queue' | ||
5 | |||
6 | function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) { | ||
7 | return isStreamingPlaylist(videoOrPlaylist) | ||
8 | ? videoOrPlaylist.Video | ||
9 | : videoOrPlaylist | ||
10 | } | ||
11 | |||
12 | function addOptimizeOrMergeAudioJob (video: MVideo, videoFile: MVideoFile) { | ||
13 | let dataInput: VideoTranscodingPayload | ||
14 | |||
15 | if (videoFile.isAudio()) { | ||
16 | dataInput = { | ||
17 | type: 'merge-audio' as 'merge-audio', | ||
18 | resolution: DEFAULT_AUDIO_RESOLUTION, | ||
19 | videoUUID: video.uuid, | ||
20 | isNewVideo: true | ||
21 | } | ||
22 | } else { | ||
23 | dataInput = { | ||
24 | type: 'optimize' as 'optimize', | ||
25 | videoUUID: video.uuid, | ||
26 | isNewVideo: true | ||
27 | } | ||
28 | } | ||
29 | |||
30 | return JobQueue.Instance.createJobWithPromise({ type: 'video-transcoding', payload: dataInput }) | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | addOptimizeOrMergeAudioJob, | ||
35 | extractVideo | ||
36 | } | ||
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 45899818e..580606a68 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -3,7 +3,7 @@ import { ActivityDelete, ActivityPubSignature } from '../../shared' | |||
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' | 4 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' |
5 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' | 5 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' |
6 | import { getOrCreateActorAndServerAndModel } from '../lib/activitypub' | 6 | import { getOrCreateActorAndServerAndModel } from '../lib/activitypub/actor' |
7 | import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' | 7 | import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger' |
8 | import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' | 8 | import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' |
9 | import { getAPId } from '@server/helpers/activitypub' | 9 | import { getAPId } from '@server/helpers/activitypub' |
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts index 7582f65e7..7350be5d5 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/middlewares/validators/activitypub/activity.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' | 2 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getServerActor } from '../../../helpers/utils' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | 5 | ||
6 | async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 6 | async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
7 | logger.debug('Checking activity pub parameters') | 7 | logger.debug('Checking activity pub parameters') |
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts index b2183437c..c00a7e4df 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/middlewares/validators/blocklist.ts | |||
@@ -6,9 +6,9 @@ import { AccountBlocklistModel } from '../../models/account/account-blocklist' | |||
6 | import { isHostValid } from '../../helpers/custom-validators/servers' | 6 | import { isHostValid } from '../../helpers/custom-validators/servers' |
7 | import { ServerBlocklistModel } from '../../models/server/server-blocklist' | 7 | import { ServerBlocklistModel } from '../../models/server/server-blocklist' |
8 | import { ServerModel } from '../../models/server/server' | 8 | import { ServerModel } from '../../models/server/server' |
9 | import { getServerActor } from '../../helpers/utils' | ||
10 | import { WEBSERVER } from '../../initializers/constants' | 9 | import { WEBSERVER } from '../../initializers/constants' |
11 | import { doesAccountNameWithHostExist } from '../../helpers/middlewares' | 10 | import { doesAccountNameWithHostExist } from '../../helpers/middlewares' |
11 | import { getServerActor } from '@server/models/application/application' | ||
12 | 12 | ||
13 | const blockAccountValidator = [ | 13 | const blockAccountValidator = [ |
14 | body('accountName').exists().withMessage('Should have an account name with host'), | 14 | body('accountName').exists().withMessage('Should have an account name with host'), |
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index a98d32d86..7808135f7 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts | |||
@@ -3,7 +3,6 @@ import { body, param, query } from 'express-validator' | |||
3 | import { isTestInstance } from '../../helpers/core-utils' | 3 | import { isTestInstance } from '../../helpers/core-utils' |
4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' | 4 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { getServerActor } from '../../helpers/utils' | ||
7 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' | 6 | import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' |
8 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 7 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
9 | import { areValidationErrors } from './utils' | 8 | import { areValidationErrors } from './utils' |
@@ -12,6 +11,7 @@ import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger' | |||
12 | import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 11 | import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
13 | import { MActorFollowActorsDefault } from '@server/typings/models' | 12 | import { MActorFollowActorsDefault } from '@server/typings/models' |
14 | import { isFollowStateValid } from '@server/helpers/custom-validators/follows' | 13 | import { isFollowStateValid } from '@server/helpers/custom-validators/follows' |
14 | import { getServerActor } from '@server/models/application/application' | ||
15 | 15 | ||
16 | const listFollowsValidator = [ | 16 | const listFollowsValidator = [ |
17 | query('state') | 17 | query('state') |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 3a7869354..867c05fc1 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -38,7 +38,6 @@ import { checkUserCanTerminateOwnershipChange, doesChangeVideoOwnershipExist } f | |||
38 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' | 38 | import { VideoChangeOwnershipAccept } from '../../../../shared/models/videos/video-change-ownership-accept.model' |
39 | import { AccountModel } from '../../../models/account/account' | 39 | import { AccountModel } from '../../../models/account/account' |
40 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' | 40 | import { isNSFWQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search' |
41 | import { getServerActor } from '../../../helpers/utils' | ||
42 | import { CONFIG } from '../../../initializers/config' | 41 | import { CONFIG } from '../../../initializers/config' |
43 | import { isLocalVideoAccepted } from '../../../lib/moderation' | 42 | import { isLocalVideoAccepted } from '../../../lib/moderation' |
44 | import { Hooks } from '../../../lib/plugins/hooks' | 43 | import { Hooks } from '../../../lib/plugins/hooks' |
@@ -50,6 +49,7 @@ import { | |||
50 | } from '../../../helpers/middlewares' | 49 | } from '../../../helpers/middlewares' |
51 | import { MVideoFullLight } from '@server/typings/models' | 50 | import { MVideoFullLight } from '@server/typings/models' |
52 | import { getVideoWithAttributes } from '../../../helpers/video' | 51 | import { getVideoWithAttributes } from '../../../helpers/video' |
52 | import { getServerActor } from '@server/models/application/application' | ||
53 | 53 | ||
54 | const videosAddValidator = getCommonVideoEditAttributes().concat([ | 54 | const videosAddValidator = getCommonVideoEditAttributes().concat([ |
55 | body('videofile') | 55 | body('videofile') |
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 5a8e450a5..85a371026 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -20,7 +20,6 @@ import { | |||
20 | import { FollowState } from '../../../shared/models/actors' | 20 | import { FollowState } from '../../../shared/models/actors' |
21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' | 21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' |
22 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
23 | import { getServerActor } from '../../helpers/utils' | ||
24 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | 23 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' |
25 | import { ServerModel } from '../server/server' | 24 | import { ServerModel } from '../server/server' |
26 | import { createSafeIn, getFollowsSort, getSort } from '../utils' | 25 | import { createSafeIn, getFollowsSort, getSort } from '../utils' |
@@ -37,6 +36,7 @@ import { | |||
37 | } from '@server/typings/models' | 36 | } from '@server/typings/models' |
38 | import { ActivityPubActorType } from '@shared/models' | 37 | import { ActivityPubActorType } from '@shared/models' |
39 | import { VideoModel } from '@server/models/video/video' | 38 | import { VideoModel } from '@server/models/video/video' |
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | 40 | ||
41 | @Table({ | 41 | @Table({ |
42 | tableName: 'actorFollow', | 42 | tableName: 'actorFollow', |
diff --git a/server/models/application/application.ts b/server/models/application/application.ts index 81320b9af..3bba2c70e 100644 --- a/server/models/application/application.ts +++ b/server/models/application/application.ts | |||
@@ -1,5 +1,16 @@ | |||
1 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' | 1 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' |
2 | import { AccountModel } from '../account/account' | 2 | import { AccountModel } from '../account/account' |
3 | import * as memoizee from 'memoizee' | ||
4 | |||
5 | export const getServerActor = memoizee(async function () { | ||
6 | const application = await ApplicationModel.load() | ||
7 | if (!application) throw Error('Could not load Application from database.') | ||
8 | |||
9 | const actor = application.Account.Actor | ||
10 | actor.Account = application.Account | ||
11 | |||
12 | return actor | ||
13 | }, { promise: true }) | ||
3 | 14 | ||
4 | @DefaultScope(() => ({ | 15 | @DefaultScope(() => ({ |
5 | include: [ | 16 | include: [ |
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 857b9eca6..6021408bf 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -17,7 +17,6 @@ import { getSort, getVideoSort, parseAggregateResult, throwIfNotValid } from '.. | |||
17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
18 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' | 18 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' |
19 | import { VideoFileModel } from '../video/video-file' | 19 | import { VideoFileModel } from '../video/video-file' |
20 | import { getServerActor } from '../../helpers/utils' | ||
21 | import { VideoModel } from '../video/video' | 20 | import { VideoModel } from '../video/video' |
22 | import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy' | 21 | import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy' |
23 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
@@ -37,6 +36,7 @@ import { | |||
37 | StreamingPlaylistRedundancyInformation, | 36 | StreamingPlaylistRedundancyInformation, |
38 | VideoRedundancy | 37 | VideoRedundancy |
39 | } from '@shared/models/redundancy/video-redundancy.model' | 38 | } from '@shared/models/redundancy/video-redundancy.model' |
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | 40 | ||
41 | export enum ScopeNames { | 41 | export enum ScopeNames { |
42 | WITH_VIDEO = 'WITH_VIDEO' | 42 | WITH_VIDEO = 'WITH_VIDEO' |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 7cdff8c2c..b7ed6240e 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -9,7 +9,6 @@ import { ActorModel } from '../activitypub/actor' | |||
9 | import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' | 9 | import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' |
10 | import { VideoModel } from './video' | 10 | import { VideoModel } from './video' |
11 | import { VideoChannelModel } from './video-channel' | 11 | import { VideoChannelModel } from './video-channel' |
12 | import { getServerActor } from '../../helpers/utils' | ||
13 | import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' | 12 | import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' |
14 | import { regexpCapture } from '../../helpers/regexp' | 13 | import { regexpCapture } from '../../helpers/regexp' |
15 | import { uniq } from 'lodash' | 14 | import { uniq } from 'lodash' |
@@ -28,6 +27,7 @@ import { | |||
28 | } from '../../typings/models/video' | 27 | } from '../../typings/models/video' |
29 | import { MUserAccountId } from '@server/typings/models' | 28 | import { MUserAccountId } from '@server/typings/models' |
30 | import { VideoPrivacy } from '@shared/models' | 29 | import { VideoPrivacy } from '@shared/models' |
30 | import { getServerActor } from '@server/models/application/application' | ||
31 | 31 | ||
32 | enum ScopeNames { | 32 | enum ScopeNames { |
33 | WITH_ACCOUNT = 'WITH_ACCOUNT', | 33 | WITH_ACCOUNT = 'WITH_ACCOUNT', |
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 365c9581e..0d3c5a8ac 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | getVideoDislikesActivityPubUrl, | 8 | getVideoDislikesActivityPubUrl, |
9 | getVideoLikesActivityPubUrl, | 9 | getVideoLikesActivityPubUrl, |
10 | getVideoSharesActivityPubUrl | 10 | getVideoSharesActivityPubUrl |
11 | } from '../../lib/activitypub' | 11 | } from '../../lib/activitypub/url' |
12 | import { isArray } from '../../helpers/custom-validators/misc' | 12 | import { isArray } from '../../helpers/custom-validators/misc' |
13 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | 13 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' |
14 | import { | 14 | import { |
@@ -23,7 +23,7 @@ import { | |||
23 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' | 23 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' |
24 | import { VideoFile } from '@shared/models/videos/video-file.model' | 24 | import { VideoFile } from '@shared/models/videos/video-file.model' |
25 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 25 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
26 | import { extractVideo } from '@server/lib/videos' | 26 | import { extractVideo } from '@server/helpers/video' |
27 | 27 | ||
28 | export type VideoFormattingJSONOptions = { | 28 | export type VideoFormattingJSONOptions = { |
29 | completeDescription?: boolean | 29 | completeDescription?: boolean |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ccb9d64ca..96b96e5ac 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -43,7 +43,6 @@ import { | |||
43 | } from '../../helpers/custom-validators/videos' | 43 | } from '../../helpers/custom-validators/videos' |
44 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' | 44 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' |
45 | import { logger } from '../../helpers/logger' | 45 | import { logger } from '../../helpers/logger' |
46 | import { getServerActor } from '../../helpers/utils' | ||
47 | import { | 46 | import { |
48 | ACTIVITY_PUB, | 47 | ACTIVITY_PUB, |
49 | API_VERSION, | 48 | API_VERSION, |
@@ -126,6 +125,7 @@ import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilena | |||
126 | import { ModelCache } from '@server/models/model-cache' | 125 | import { ModelCache } from '@server/models/model-cache' |
127 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' | 126 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' |
128 | import { buildNSFWFilter } from '@server/helpers/express-utils' | 127 | import { buildNSFWFilter } from '@server/helpers/express-utils' |
128 | import { getServerActor } from '@server/models/application/application' | ||
129 | 129 | ||
130 | export enum ScopeNames { | 130 | export enum ScopeNames { |
131 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', | 131 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', |
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 7e58bf065..ac4bc7c6a 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts | |||
@@ -4,10 +4,11 @@ import 'mocha' | |||
4 | 4 | ||
5 | import { cleanupTests, closeAllSequelize, flushAndRunMultipleServers, ServerInfo, setActorField } from '../../../../shared/extra-utils' | 5 | import { cleanupTests, closeAllSequelize, flushAndRunMultipleServers, ServerInfo, setActorField } from '../../../../shared/extra-utils' |
6 | import { HTTP_SIGNATURE } from '../../../initializers/constants' | 6 | import { HTTP_SIGNATURE } from '../../../initializers/constants' |
7 | import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' | 7 | import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' |
8 | import * as chai from 'chai' | 8 | import * as chai from 'chai' |
9 | import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' | 9 | import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' |
10 | import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub' | 10 | import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub' |
11 | import { buildDigest } from '@server/helpers/peertube-crypto' | ||
11 | 12 | ||
12 | const expect = chai.expect | 13 | const expect = chai.expect |
13 | 14 | ||
diff --git a/shared/models/server/emailer.model.ts b/shared/models/server/emailer.model.ts new file mode 100644 index 000000000..2d8feda81 --- /dev/null +++ b/shared/models/server/emailer.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export type SendEmailOptions = { | ||
2 | to: string[] | ||
3 | subject: string | ||
4 | text: string | ||
5 | |||
6 | fromDisplayName?: string | ||
7 | replyTo?: string | ||
8 | } | ||
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts index bf61ab270..b0afb2c66 100644 --- a/shared/models/server/index.ts +++ b/shared/models/server/index.ts | |||
@@ -2,6 +2,7 @@ export * from './about.model' | |||
2 | export * from './contact-form.model' | 2 | export * from './contact-form.model' |
3 | export * from './custom-config.model' | 3 | export * from './custom-config.model' |
4 | export * from './debug.model' | 4 | export * from './debug.model' |
5 | export * from './emailer.model' | ||
5 | export * from './job.model' | 6 | export * from './job.model' |
6 | export * from './server-config.model' | 7 | export * from './server-config.model' |
7 | export * from './server-stats.model' | 8 | export * from './server-stats.model' |
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index cf29d20d4..694361276 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -1,3 +1,7 @@ | |||
1 | import { ContextType } from '@server/helpers/activitypub' | ||
2 | import { SendEmailOptions } from './emailer.model' | ||
3 | import { VideoResolution } from '@shared/models' | ||
4 | |||
1 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 5 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' |
2 | 6 | ||
3 | export type JobType = | 7 | export type JobType = |
@@ -23,3 +27,99 @@ export interface Job { | |||
23 | finishedOn: Date | string | 27 | finishedOn: Date | string |
24 | processedOn: Date | string | 28 | processedOn: Date | string |
25 | } | 29 | } |
30 | |||
31 | export type ActivitypubHttpBroadcastPayload = { | ||
32 | uris: string[] | ||
33 | signatureActorId?: number | ||
34 | body: any | ||
35 | contextType?: ContextType | ||
36 | } | ||
37 | |||
38 | export type ActivitypubFollowPayload = { | ||
39 | followerActorId: number | ||
40 | name: string | ||
41 | host: string | ||
42 | isAutoFollow?: boolean | ||
43 | assertIsChannel?: boolean | ||
44 | } | ||
45 | |||
46 | export type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists' | ||
47 | export type ActivitypubHttpFetcherPayload = { | ||
48 | uri: string | ||
49 | type: FetchType | ||
50 | videoId?: number | ||
51 | accountId?: number | ||
52 | } | ||
53 | |||
54 | export type ActivitypubHttpUnicastPayload = { | ||
55 | uri: string | ||
56 | signatureActorId?: number | ||
57 | body: any | ||
58 | contextType?: ContextType | ||
59 | } | ||
60 | |||
61 | export type RefreshPayload = { | ||
62 | type: 'video' | 'video-playlist' | 'actor' | ||
63 | url: string | ||
64 | } | ||
65 | |||
66 | export type EmailPayload = SendEmailOptions | ||
67 | |||
68 | export type VideoFileImportPayload = { | ||
69 | videoUUID: string | ||
70 | filePath: string | ||
71 | } | ||
72 | |||
73 | export type VideoImportYoutubeDLPayload = { | ||
74 | type: 'youtube-dl' | ||
75 | videoImportId: number | ||
76 | |||
77 | generateThumbnail: boolean | ||
78 | generatePreview: boolean | ||
79 | |||
80 | fileExt?: string | ||
81 | } | ||
82 | export type VideoImportTorrentPayload = { | ||
83 | type: 'magnet-uri' | 'torrent-file' | ||
84 | videoImportId: number | ||
85 | } | ||
86 | export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload | ||
87 | |||
88 | export type VideoRedundancyPayload = { | ||
89 | videoId: number | ||
90 | } | ||
91 | |||
92 | // Video transcoding payloads | ||
93 | |||
94 | interface BaseTranscodingPayload { | ||
95 | videoUUID: string | ||
96 | isNewVideo?: boolean | ||
97 | } | ||
98 | |||
99 | interface HLSTranscodingPayload extends BaseTranscodingPayload { | ||
100 | type: 'hls' | ||
101 | isPortraitMode?: boolean | ||
102 | resolution: VideoResolution | ||
103 | copyCodecs: boolean | ||
104 | } | ||
105 | |||
106 | export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
107 | type: 'new-resolution' | ||
108 | isPortraitMode?: boolean | ||
109 | resolution: VideoResolution | ||
110 | } | ||
111 | |||
112 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
113 | type: 'merge-audio' | ||
114 | resolution: VideoResolution | ||
115 | } | ||
116 | |||
117 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
118 | type: 'optimize' | ||
119 | } | ||
120 | |||
121 | export type VideoTranscodingPayload = | ||
122 | HLSTranscodingPayload | ||
123 | | NewResolutionTranscodingPayload | ||
124 | | OptimizeTranscodingPayload | ||
125 | | MergeAudioTranscodingPayload | ||