diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 11:16:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 11:16:08 +0100 |
commit | da854ddd502cd70685ef779c673b9e63757b8aa0 (patch) | |
tree | 21501d170cceaa044a5f23449cbd2eb47fd6415d /server/lib/activitypub/actor.ts | |
parent | f40bbe3146553ef45515ee6b6d93ce6028f045ca (diff) | |
download | PeerTube-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.ts | 28 |
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' | |||
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 |