aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
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/helpers
parentf40bbe3146553ef45515ee6b6d93ce6028f045ca (diff)
downloadPeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.gz
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.tar.zst
PeerTube-da854ddd502cd70685ef779c673b9e63757b8aa0.zip
Propagate old comment on new follow
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/activitypub/actor.ts3
-rw-r--r--server/helpers/custom-validators/activitypub/announce.ts1
-rw-r--r--server/helpers/custom-validators/activitypub/index.ts8
-rw-r--r--server/helpers/index.ts9
-rw-r--r--server/helpers/requests.ts8
-rw-r--r--server/helpers/webfinger.ts2
6 files changed, 10 insertions, 21 deletions
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts
index ec8da3350..630bace30 100644
--- a/server/helpers/custom-validators/activitypub/actor.ts
+++ b/server/helpers/custom-validators/activitypub/actor.ts
@@ -46,7 +46,8 @@ function isActorPrivateKeyValid (privateKey: string) {
46} 46}
47 47
48function isRemoteActorValid (remoteActor: any) { 48function isRemoteActorValid (remoteActor: any) {
49 return isActivityPubUrlValid(remoteActor.id) && 49 return exists(remoteActor) &&
50 isActivityPubUrlValid(remoteActor.id) &&
50 isActorTypeValid(remoteActor.type) && 51 isActorTypeValid(remoteActor.type) &&
51 isActivityPubUrlValid(remoteActor.following) && 52 isActivityPubUrlValid(remoteActor.following) &&
52 isActivityPubUrlValid(remoteActor.followers) && 53 isActivityPubUrlValid(remoteActor.followers) &&
diff --git a/server/helpers/custom-validators/activitypub/announce.ts b/server/helpers/custom-validators/activitypub/announce.ts
index 1baea4f60..7dd1d6988 100644
--- a/server/helpers/custom-validators/activitypub/announce.ts
+++ b/server/helpers/custom-validators/activitypub/announce.ts
@@ -2,7 +2,6 @@ import { isActivityPubUrlValid, isBaseActivityValid } from './misc'
2import { isVideoTorrentCreateActivityValid } from './videos' 2import { isVideoTorrentCreateActivityValid } from './videos'
3 3
4function isAnnounceActivityValid (activity: any) { 4function isAnnounceActivityValid (activity: any) {
5 console.log(activity)
6 return isBaseActivityValid(activity, 'Announce') && 5 return isBaseActivityValid(activity, 'Announce') &&
7 ( 6 (
8 isVideoTorrentCreateActivityValid(activity.object) || 7 isVideoTorrentCreateActivityValid(activity.object) ||
diff --git a/server/helpers/custom-validators/activitypub/index.ts b/server/helpers/custom-validators/activitypub/index.ts
deleted file mode 100644
index ba411f1c6..000000000
--- a/server/helpers/custom-validators/activitypub/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
1export * from './actor'
2export * from './activity'
3export * from './misc'
4export * from './signature'
5export * from './undo'
6export * from './video-channels'
7export * from './videos'
8export * from './view'
diff --git a/server/helpers/index.ts b/server/helpers/index.ts
deleted file mode 100644
index d96bc48e9..000000000
--- a/server/helpers/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
1export * from './activitypub'
2export * from './core-utils'
3export * from './logger'
4export * from './ffmpeg-utils'
5export * from './database-utils'
6export * from './peertube-crypto'
7export * from './requests'
8export * from './utils'
9export * from './webfinger'
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 4b1deeadc..ce185a2c0 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -1,8 +1,14 @@
1import * as Promise from 'bluebird' 1import * as Promise from 'bluebird'
2import { createWriteStream } from 'fs' 2import { createWriteStream } from 'fs'
3import * as request from 'request' 3import * as request from 'request'
4import { ACTIVITY_PUB } from '../initializers'
5
6function doRequest (requestOptions: request.CoreOptions & request.UriOptions & { activityPub?: boolean }) {
7 if (requestOptions.activityPub === true) {
8 if (!Array.isArray(requestOptions.headers)) requestOptions.headers = {}
9 requestOptions.headers['accept'] = ACTIVITY_PUB.ACCEPT_HEADER
10 }
4 11
5function doRequest (requestOptions: request.CoreOptions & request.UriOptions) {
6 return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => { 12 return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => {
7 request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body })) 13 request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))
8 }) 14 })
diff --git a/server/helpers/webfinger.ts b/server/helpers/webfinger.ts
index 76444fbe3..de8d52c9b 100644
--- a/server/helpers/webfinger.ts
+++ b/server/helpers/webfinger.ts
@@ -2,7 +2,7 @@ import * as WebFinger from 'webfinger.js'
2import { WebFingerData } from '../../shared' 2import { WebFingerData } from '../../shared'
3import { ActorModel } from '../models/activitypub/actor' 3import { ActorModel } from '../models/activitypub/actor'
4import { isTestInstance } from './core-utils' 4import { isTestInstance } from './core-utils'
5import { isActivityPubUrlValid } from './custom-validators/activitypub' 5import { isActivityPubUrlValid } from './custom-validators/activitypub/misc'
6 6
7const webfinger = new WebFinger({ 7const webfinger = new WebFinger({
8 webfist_fallback: false, 8 webfist_fallback: false,