diff options
author | buoyantair <buoyantair@protonmail.com> | 2018-11-16 02:37:16 +0530 |
---|---|---|
committer | buoyantair <buoyantair@protonmail.com> | 2018-11-16 02:37:16 +0530 |
commit | ae28cdf327d782e629379eee1999096ca2a5d74b (patch) | |
tree | bfe0d4b3a232d75161fe5bba9196553a388fc02a /server/helpers/activitypub.ts | |
parent | d4681c0074ba51c62a3aeb9fb3f2cd071dd21e32 (diff) | |
parent | 8cf998733496d44fa564e2e252356b871756c984 (diff) | |
download | PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.gz PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.tar.zst PeerTube-ae28cdf327d782e629379eee1999096ca2a5d74b.zip |
Merge from upstream
Diffstat (limited to 'server/helpers/activitypub.ts')
-rw-r--r-- | server/helpers/activitypub.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts index 278010e78..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, { |
@@ -24,7 +25,7 @@ function activityPubContextify <T> (data: T) { | |||
24 | sensitive: 'as:sensitive', | 25 | sensitive: 'as:sensitive', |
25 | language: 'sc:inLanguage', | 26 | language: 'sc:inLanguage', |
26 | views: 'sc:Number', | 27 | views: 'sc:Number', |
27 | stats: 'sc:Number', | 28 | state: 'sc:Number', |
28 | size: 'sc:Number', | 29 | size: 'sc:Number', |
29 | fps: 'sc:Number', | 30 | fps: 'sc:Number', |
30 | commentsEnabled: 'sc:Boolean', | 31 | commentsEnabled: 'sc:Boolean', |
@@ -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, |