aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/url.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/url.ts')
-rw-r--r--server/lib/activitypub/url.ts31
1 files changed, 28 insertions, 3 deletions
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts
index 338398f2b..50be4fac9 100644
--- a/server/lib/activitypub/url.ts
+++ b/server/lib/activitypub/url.ts
@@ -1,4 +1,4 @@
1import { WEBSERVER } from '../../initializers/constants' 1import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants'
2import { 2import {
3 MAbuseFull, 3 MAbuseFull,
4 MAbuseId, 4 MAbuseId,
@@ -10,7 +10,8 @@ import {
10 MVideoId, 10 MVideoId,
11 MVideoPlaylistElement, 11 MVideoPlaylistElement,
12 MVideoUrl, 12 MVideoUrl,
13 MVideoUUID 13 MVideoUUID,
14 MVideoWithHost
14} from '../../types/models' 15} from '../../types/models'
15import { MVideoFileVideoUUID } from '../../types/models/video/video-file' 16import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
16import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' 17import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
@@ -121,6 +122,27 @@ function getAbuseTargetUrl (abuse: MAbuseFull) {
121 abuse.FlaggedAccount.Actor.url 122 abuse.FlaggedAccount.Actor.url
122} 123}
123 124
125// ---------------------------------------------------------------------------
126
127function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
128 if (!scheme) scheme = REMOTE_SCHEME.HTTP
129
130 const host = video.VideoChannel.Actor.Server.host
131
132 return scheme + '://' + host + path
133}
134
135// ---------------------------------------------------------------------------
136
137function checkUrlsSameHost (url1: string, url2: string) {
138 const idHost = new URL(url1).host
139 const actorHost = new URL(url2).host
140
141 return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
142}
143
144// ---------------------------------------------------------------------------
145
124export { 146export {
125 getLocalVideoActivityPubUrl, 147 getLocalVideoActivityPubUrl,
126 getLocalVideoPlaylistActivityPubUrl, 148 getLocalVideoPlaylistActivityPubUrl,
@@ -145,5 +167,8 @@ export {
145 getLocalVideoCommentsActivityPubUrl, 167 getLocalVideoCommentsActivityPubUrl,
146 getLocalVideoLikesActivityPubUrl, 168 getLocalVideoLikesActivityPubUrl,
147 getLocalVideoDislikesActivityPubUrl, 169 getLocalVideoDislikesActivityPubUrl,
148 getAbuseTargetUrl 170
171 getAbuseTargetUrl,
172 checkUrlsSameHost,
173 buildRemoteVideoBaseUrl
149} 174}