diff options
author | Chocobozzz <me@florianbigard.com> | 2018-11-14 15:01:28 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-11-14 16:32:27 +0100 |
commit | 5c6d985faeef1d6793d3f44ca6374f1a9b722806 (patch) | |
tree | 567e31a84e721bf762189582f92ac2ec5c402bcc /server/helpers/activitypub.ts | |
parent | df66d81583e07ce049daeeef1edc6a87b57b3684 (diff) | |
download | PeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.tar.gz PeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.tar.zst PeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.zip |
Check activities host
Diffstat (limited to 'server/helpers/activitypub.ts')
-rw-r--r-- | server/helpers/activitypub.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index b0bcfe824..4bf6e387d 100644 --- a/server/helpers/activitypub.ts +++ b/server/helpers/activitypub.ts | |||
@@ -6,6 +6,7 @@ import { ACTIVITY_PUB } from '../initializers' | |||
6 | import { ActorModel } from '../models/activitypub/actor' | 6 | import { ActorModel } from '../models/activitypub/actor' |
7 | import { signJsonLDObject } from './peertube-crypto' | 7 | import { signJsonLDObject } from './peertube-crypto' |
8 | import { pageToStartAndCount } from './core-utils' | 8 | import { pageToStartAndCount } from './core-utils' |
9 | import { parse } from 'url' | ||
9 | 10 | ||
10 | function activityPubContextify <T> (data: T) { | 11 | function activityPubContextify <T> (data: T) { |
11 | return Object.assign(data, { | 12 | return Object.assign(data, { |
@@ -111,9 +112,17 @@ function getActorUrl (activityActor: string | ActivityPubActor) { | |||
111 | return activityActor.id | 112 | return activityActor.id |
112 | } | 113 | } |
113 | 114 | ||
115 | function checkUrlsSameHost (url1: string, url2: string) { | ||
116 | const idHost = parse(url1).host | ||
117 | const actorHost = parse(url2).host | ||
118 | |||
119 | return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase() | ||
120 | } | ||
121 | |||
114 | // --------------------------------------------------------------------------- | 122 | // --------------------------------------------------------------------------- |
115 | 123 | ||
116 | export { | 124 | export { |
125 | checkUrlsSameHost, | ||
117 | getActorUrl, | 126 | getActorUrl, |
118 | activityPubContextify, | 127 | activityPubContextify, |
119 | activityPubCollectionPagination, | 128 | activityPubCollectionPagination, |