aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/video-comments.ts1
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler.ts7
-rw-r--r--server/lib/jobs/activitypub-http-job-scheduler/activitypub-http-unicast-handler.ts3
-rw-r--r--server/middlewares/activitypub.ts1
-rw-r--r--server/models/activitypub/actor-follow.ts28
-rw-r--r--server/models/activitypub/actor.ts3
-rw-r--r--server/tests/api/server/handle-down.ts4
7 files changed, 44 insertions, 3 deletions
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 17c86a381..b33ae27b1 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -81,7 +81,6 @@ async function resolveThread (url: string, comments: VideoCommentModel[] = []) {
81 // Speed up things and resolve directly the thread 81 // Speed up things and resolve directly the thread
82 if (commentFromDatabase.InReplyToVideoComment) { 82 if (commentFromDatabase.InReplyToVideoComment) {
83 const data = await VideoCommentModel.listThreadParentComments(commentFromDatabase, undefined, 'DESC') 83 const data = await VideoCommentModel.listThreadParentComments(commentFromDatabase, undefined, 'DESC')
84 console.log(data)
85 84
86 parentComments = parentComments.concat(data) 85 parentComments = parentComments.concat(data)
87 } 86 }
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 10423a7df..4459152db 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
@@ -4,6 +4,7 @@ import { logger } from '../../../helpers/logger'
4import { getServerActor } from '../../../helpers/utils' 4import { getServerActor } from '../../../helpers/utils'
5import { ACTIVITY_PUB } from '../../../initializers' 5import { ACTIVITY_PUB } from '../../../initializers'
6import { ActorModel } from '../../../models/activitypub/actor' 6import { ActorModel } from '../../../models/activitypub/actor'
7import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
7import { JobHandler, JobScheduler } from '../job-scheduler' 8import { JobHandler, JobScheduler } from '../job-scheduler'
8 9
9import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler' 10import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler'
@@ -35,6 +36,12 @@ async function maybeRetryRequestLater (err: Error, payload: ActivityPubHttpPaylo
35 if (attemptNumber < ACTIVITY_PUB.MAX_HTTP_ATTEMPT) { 36 if (attemptNumber < ACTIVITY_PUB.MAX_HTTP_ATTEMPT) {
36 logger.debug('Retrying request to %s (attempt %d/%d).', uri, attemptNumber, ACTIVITY_PUB.MAX_HTTP_ATTEMPT, err) 37 logger.debug('Retrying request to %s (attempt %d/%d).', uri, attemptNumber, ACTIVITY_PUB.MAX_HTTP_ATTEMPT, err)
37 38
39 const actor = await ActorFollowModel.loadByFollowerInbox(uri, undefined)
40 if (!actor) {
41 logger.debug('Actor %s is not a follower, do not retry the request.', uri)
42 return false
43 }
44
38 const newPayload = Object.assign(payload, { 45 const newPayload = Object.assign(payload, {
39 uris: [ uri ], 46 uris: [ uri ],
40 attemptNumber 47 attemptNumber
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 deedf8402..54a7504e8 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
@@ -6,10 +6,11 @@ import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRe
6async function process (payload: ActivityPubHttpPayload, jobId: number) { 6async function process (payload: ActivityPubHttpPayload, jobId: number) {
7 logger.info('Processing ActivityPub unicast in job %d.', jobId) 7 logger.info('Processing ActivityPub unicast in job %d.', jobId)
8 8
9 const uri = payload.uris[0]
10
9 const body = await computeBody(payload) 11 const body = await computeBody(payload)
10 const httpSignatureOptions = await buildSignedRequestOptions(payload) 12 const httpSignatureOptions = await buildSignedRequestOptions(payload)
11 13
12 const uri = payload.uris[0]
13 const options = { 14 const options = {
14 method: 'POST', 15 method: 'POST',
15 uri, 16 uri,
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index c7102b6bf..1488b42ab 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -35,7 +35,6 @@ async function checkSignature (req: Request, res: Response, next: NextFunction)
35function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) { 35function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
36 return (req: Request, res: Response, next: NextFunction) => { 36 return (req: Request, res: Response, next: NextFunction) => {
37 const accepted = req.accepts(ACCEPT_HEADERS) 37 const accepted = req.accepts(ACCEPT_HEADERS)
38 console.log(accepted)
39 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) { 38 if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
40 return next() 39 return next()
41 } 40 }
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 920c83d88..de5bb6f74 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -163,6 +163,34 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
163 return ActorFollowModel.findOne(query) 163 return ActorFollowModel.findOne(query)
164 } 164 }
165 165
166 static loadByFollowerInbox (url: string, t?: Sequelize.Transaction) {
167 const query = {
168 where: {
169 state: 'accepted'
170 },
171 include: [
172 {
173 model: ActorModel,
174 required: true,
175 as: 'ActorFollower',
176 where: {
177 [Sequelize.Op.or]: [
178 {
179 inboxUrl: url
180 },
181 {
182 sharedInboxUrl: url
183 }
184 ]
185 }
186 }
187 ],
188 transaction: t
189 } as any // FIXME: typings does not work
190
191 return ActorFollowModel.findOne(query)
192 }
193
166 static listFollowingForApi (id: number, start: number, count: number, sort: string) { 194 static listFollowingForApi (id: number, start: number, count: number, sort: string) {
167 const query = { 195 const query = {
168 distinct: true, 196 distinct: true,
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 6c74aa61b..17f69f7a7 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -68,6 +68,9 @@ enum ScopeNames {
68 { 68 {
69 fields: [ 'preferredUsername', 'serverId' ], 69 fields: [ 'preferredUsername', 'serverId' ],
70 unique: true 70 unique: true
71 },
72 {
73 fields: [ 'inboxUrl', 'sharedInboxUrl' ]
71 } 74 }
72 ] 75 ]
73}) 76})
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index cc1ff9a9f..6ca8cfb64 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -113,6 +113,10 @@ describe('Test handle downs', function () {
113 videos.push(resVideo.body.video) 113 videos.push(resVideo.body.video)
114 } 114 }
115 115
116 await wait(2000)
117
118 await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
119
116 // Add comments to video 2 120 // Add comments to video 2
117 { 121 {
118 const text = 'thread 1' 122 const text = 'thread 1'