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