aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/server/follows.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index e7d81f7c3..ae5413b75 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -1,19 +1,15 @@
1import * as express from 'express' 1import * as express from 'express'
2import { UserRight } from '../../../../shared/models/users' 2import { UserRight } from '../../../../shared/models/users'
3import { getFormattedObjects, getServerActor, loadActorUrlOrGetFromWebfinger, logger, retryTransactionWrapper } from '../../../helpers' 3import {
4import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers' 4 getFormattedObjects, getServerActor, loadActorUrlOrGetFromWebfinger, logger, retryTransactionWrapper,
5 sanitizeHost
6} from '../../../helpers'
7import { REMOTE_SCHEME, sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers'
5import { getOrCreateActorAndServerAndModel } from '../../../lib/activitypub' 8import { getOrCreateActorAndServerAndModel } from '../../../lib/activitypub'
6import { sendFollow, sendUndoFollow } from '../../../lib/activitypub/send' 9import { sendFollow, sendUndoFollow } from '../../../lib/activitypub/send'
7import { 10import {
8 asyncMiddleware, 11 asyncMiddleware, authenticate, ensureUserHasRight, paginationValidator, removeFollowingValidator, setBodyHostsPort,
9 authenticate, 12 setFollowersSort, setFollowingSort, setPagination
10 ensureUserHasRight,
11 paginationValidator,
12 removeFollowingValidator,
13 setBodyHostsPort,
14 setFollowersSort,
15 setFollowingSort,
16 setPagination
17} from '../../../middlewares' 13} from '../../../middlewares'
18import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' 14import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators'
19import { ActorModel } from '../../../models/activitypub/actor' 15import { ActorModel } from '../../../models/activitypub/actor'
@@ -82,10 +78,12 @@ async function followRetry (req: express.Request, res: express.Response, next: e
82 const actorName = SERVER_ACTOR_NAME 78 const actorName = SERVER_ACTOR_NAME
83 79
84 for (const host of hosts) { 80 for (const host of hosts) {
81 const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP)
82
85 // We process each host in a specific transaction 83 // We process each host in a specific transaction
86 // First, we add the follow request in the database 84 // First, we add the follow request in the database
87 // Then we send the follow request to other actor 85 // Then we send the follow request to other actor
88 const p = loadActorUrlOrGetFromWebfinger(actorName, host) 86 const p = loadActorUrlOrGetFromWebfinger(actorName, sanitizedHost)
89 .then(actorUrl => getOrCreateActorAndServerAndModel(actorUrl)) 87 .then(actorUrl => getOrCreateActorAndServerAndModel(actorUrl))
90 .then(targetActor => { 88 .then(targetActor => {
91 const options = { 89 const options = {
@@ -95,7 +93,7 @@ async function followRetry (req: express.Request, res: express.Response, next: e
95 93
96 return retryTransactionWrapper(follow, options) 94 return retryTransactionWrapper(follow, options)
97 }) 95 })
98 .catch(err => logger.warn('Cannot follow server %s.', host, err)) 96 .catch(err => logger.warn('Cannot follow server %s.', sanitizedHost, err))
99 97
100 tasks.push(p) 98 tasks.push(p)
101 } 99 }