aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/url.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
committerChocobozzz <me@florianbigard.com>2020-11-20 11:21:08 +0100
commitde94ac86a211dec657332d964693857ec235ce40 (patch)
tree3bff96a40e7c862d83561a26249992b07331b0a2 /server/lib/activitypub/url.ts
parent3fba4b6bce69247b1d37f923894d8f44818a891c (diff)
downloadPeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.gz
PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.zst
PeerTube-de94ac86a211dec657332d964693857ec235ce40.zip
Fix incorrect IDs in AP federation
Diffstat (limited to 'server/lib/activitypub/url.ts')
-rw-r--r--server/lib/activitypub/url.ts93
1 files changed, 47 insertions, 46 deletions
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts
index 58030be2c..ad6a1d1fd 100644
--- a/server/lib/activitypub/url.ts
+++ b/server/lib/activitypub/url.ts
@@ -1,102 +1,102 @@
1import { WEBSERVER } from '../../initializers/constants' 1import { WEBSERVER } from '../../initializers/constants'
2import { 2import {
3 MAbuseId,
3 MActor, 4 MActor,
4 MActorFollowActors, 5 MActorFollowActors,
5 MActorId, 6 MActorId,
6 MActorUrl, 7 MActorUrl,
7 MCommentId, 8 MCommentId,
8 MVideoId, 9 MVideoId,
10 MVideoPlaylistElement,
9 MVideoUrl, 11 MVideoUrl,
10 MVideoUUID, 12 MVideoUUID
11 MAbuseId,
12 MVideoPlaylistElement
13} from '../../types/models' 13} from '../../types/models'
14import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
15import { MVideoFileVideoUUID } from '../../types/models/video/video-file' 14import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
15import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
16import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' 16import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
17 17
18function getVideoActivityPubUrl (video: MVideoUUID) { 18function getLocalVideoActivityPubUrl (video: MVideoUUID) {
19 return WEBSERVER.URL + '/videos/watch/' + video.uuid 19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
20} 20}
21 21
22function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { 22function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid 23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
24} 24}
25 25
26function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) { 26function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id 27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
28} 28}
29 29
30function getVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) { 30function getLocalVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) {
31 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' 31 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
32 32
33 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` 33 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
34} 34}
35 35
36function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) { 36function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` 37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
38} 38}
39 39
40function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) { 40function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id 41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
42} 42}
43 43
44function getVideoChannelActivityPubUrl (videoChannelName: string) { 44function getLocalVideoChannelActivityPubUrl (videoChannelName: string) {
45 return WEBSERVER.URL + '/video-channels/' + videoChannelName 45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
46} 46}
47 47
48function getAccountActivityPubUrl (accountName: string) { 48function getLocalAccountActivityPubUrl (accountName: string) {
49 return WEBSERVER.URL + '/accounts/' + accountName 49 return WEBSERVER.URL + '/accounts/' + accountName
50} 50}
51 51
52function getAbuseActivityPubUrl (abuse: MAbuseId) { 52function getLocalAbuseActivityPubUrl (abuse: MAbuseId) {
53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id 53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
54} 54}
55 55
56function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) { 56function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() 57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
58} 58}
59 59
60function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { 60function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
61 return byActor.url + '/likes/' + video.id 61 return byActor.url + '/likes/' + video.id
62} 62}
63 63
64function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { 64function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
65 return byActor.url + '/dislikes/' + video.id 65 return byActor.url + '/dislikes/' + video.id
66} 66}
67 67
68function getVideoSharesActivityPubUrl (video: MVideoUrl) { 68function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) {
69 return video.url + '/announces' 69 return video.url + '/announces'
70} 70}
71 71
72function getVideoCommentsActivityPubUrl (video: MVideoUrl) { 72function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) {
73 return video.url + '/comments' 73 return video.url + '/comments'
74} 74}
75 75
76function getVideoLikesActivityPubUrl (video: MVideoUrl) { 76function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) {
77 return video.url + '/likes' 77 return video.url + '/likes'
78} 78}
79 79
80function getVideoDislikesActivityPubUrl (video: MVideoUrl) { 80function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) {
81 return video.url + '/dislikes' 81 return video.url + '/dislikes'
82} 82}
83 83
84function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) { 84function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
85 return follower.url + '/follows/' + following.id 85 return follower.url + '/follows/' + following.id
86} 86}
87 87
88function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) { 88function getLocalActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
89 const follower = actorFollow.ActorFollower 89 const follower = actorFollow.ActorFollower
90 const me = actorFollow.ActorFollowing 90 const me = actorFollow.ActorFollowing
91 91
92 return follower.url + '/accepts/follows/' + me.id 92 return WEBSERVER.URL + '/accepts/follows/' + follower.id + '/' + me.id
93} 93}
94 94
95function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) { 95function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) {
96 return follower.url + '/rejects/follows/' + following.id 96 return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id
97} 97}
98 98
99function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) { 99function getLocalVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
100 return video.url + '/announces/' + byActor.id 100 return video.url + '/announces/' + byActor.id
101} 101}
102 102
@@ -113,27 +113,28 @@ function getUndoActivityPubUrl (originalUrl: string) {
113} 113}
114 114
115export { 115export {
116 getVideoActivityPubUrl, 116 getLocalVideoActivityPubUrl,
117 getVideoPlaylistElementActivityPubUrl, 117 getLocalVideoPlaylistActivityPubUrl,
118 getVideoPlaylistActivityPubUrl, 118 getLocalVideoPlaylistElementActivityPubUrl,
119 getVideoCacheStreamingPlaylistActivityPubUrl, 119 getLocalVideoCacheFileActivityPubUrl,
120 getVideoChannelActivityPubUrl, 120 getLocalVideoCacheStreamingPlaylistActivityPubUrl,
121 getAccountActivityPubUrl, 121 getLocalVideoCommentActivityPubUrl,
122 getAbuseActivityPubUrl, 122 getLocalVideoChannelActivityPubUrl,
123 getActorFollowActivityPubUrl, 123 getLocalAccountActivityPubUrl,
124 getActorFollowAcceptActivityPubUrl, 124 getLocalAbuseActivityPubUrl,
125 getVideoAnnounceActivityPubUrl, 125 getLocalActorFollowActivityPubUrl,
126 getLocalActorFollowAcceptActivityPubUrl,
127 getLocalVideoAnnounceActivityPubUrl,
126 getUpdateActivityPubUrl, 128 getUpdateActivityPubUrl,
127 getUndoActivityPubUrl, 129 getUndoActivityPubUrl,
128 getVideoViewActivityPubUrl, 130 getVideoLikeActivityPubUrlByLocalActor,
129 getVideoLikeActivityPubUrl, 131 getLocalVideoViewActivityPubUrl,
130 getVideoDislikeActivityPubUrl, 132 getVideoDislikeActivityPubUrlByLocalActor,
131 getActorFollowRejectActivityPubUrl, 133 getLocalActorFollowRejectActivityPubUrl,
132 getVideoCommentActivityPubUrl,
133 getDeleteActivityPubUrl, 134 getDeleteActivityPubUrl,
134 getVideoSharesActivityPubUrl, 135 getLocalVideoSharesActivityPubUrl,
135 getVideoCommentsActivityPubUrl, 136 getLocalVideoCommentsActivityPubUrl,
136 getVideoLikesActivityPubUrl, 137 getLocalVideoLikesActivityPubUrl,
137 getVideoDislikesActivityPubUrl, 138 getLocalVideoDislikesActivityPubUrl,
138 getVideoCacheFileActivityPubUrl 139
139} 140}