aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/actor.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 11:16:08 +0100
commitda854ddd502cd70685ef779c673b9e63757b8aa0 (patch)
tree21501d170cceaa044a5f23449cbd2eb47fd6415d /server/lib/activitypub/actor.ts
parentf40bbe3146553ef45515ee6b6d93ce6028f045ca (diff)
downloadPeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.gz
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.zst
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.zip
Propagate old comment on new follow
Diffstat (limited to 'server/lib/activitypub/actor.ts')
-rw-r--r--server/lib/activitypub/actor.ts28
1 files changed, 13 insertions, 15 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'
3import * as url from 'url' 3import * as url from 'url'
4import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub' 4import { ActivityPubActor, ActivityPubActorType } from '../../../shared/models/activitypub'
5import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects' 5import { ActivityPubAttributedTo } from '../../../shared/models/activitypub/objects'
6import { createPrivateAndPublicKeys, doRequest, logger, retryTransactionWrapper } from '../../helpers' 6import { isRemoteActorValid } from '../../helpers/custom-validators/activitypub/actor'
7import { isRemoteActorValid } from '../../helpers/custom-validators/activitypub' 7import { retryTransactionWrapper } from '../../helpers/database-utils'
8import { ACTIVITY_PUB, CONFIG, sequelizeTypescript } from '../../initializers' 8import { logger } from '../../helpers/logger'
9import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
10import { doRequest } from '../../helpers/requests'
11import { CONFIG, sequelizeTypescript } from '../../initializers'
9import { AccountModel } from '../../models/account/account' 12import { AccountModel } from '../../models/account/account'
10import { ActorModel } from '../../models/activitypub/actor' 13import { ActorModel } from '../../models/activitypub/actor'
11import { ServerModel } from '../../models/server/server' 14import { 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 {
195async function fetchActorTotalItems (url: string) { 191async 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