diff options
Diffstat (limited to 'server/lib/activitypub/url.ts')
-rw-r--r-- | server/lib/activitypub/url.ts | 93 |
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 @@ | |||
1 | import { WEBSERVER } from '../../initializers/constants' | 1 | import { WEBSERVER } from '../../initializers/constants' |
2 | import { | 2 | import { |
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' |
14 | import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' | ||
15 | import { MVideoFileVideoUUID } from '../../types/models/video/video-file' | 14 | import { MVideoFileVideoUUID } from '../../types/models/video/video-file' |
15 | import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' | ||
16 | import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' | 16 | import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' |
17 | 17 | ||
18 | function getVideoActivityPubUrl (video: MVideoUUID) { | 18 | function getLocalVideoActivityPubUrl (video: MVideoUUID) { |
19 | return WEBSERVER.URL + '/videos/watch/' + video.uuid | 19 | return WEBSERVER.URL + '/videos/watch/' + video.uuid |
20 | } | 20 | } |
21 | 21 | ||
22 | function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { | 22 | function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { |
23 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid | 23 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid |
24 | } | 24 | } |
25 | 25 | ||
26 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) { | 26 | function 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 | ||
30 | function getVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) { | 30 | function 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 | ||
36 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) { | 36 | function 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 | ||
40 | function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) { | 40 | function 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 | ||
44 | function getVideoChannelActivityPubUrl (videoChannelName: string) { | 44 | function getLocalVideoChannelActivityPubUrl (videoChannelName: string) { |
45 | return WEBSERVER.URL + '/video-channels/' + videoChannelName | 45 | return WEBSERVER.URL + '/video-channels/' + videoChannelName |
46 | } | 46 | } |
47 | 47 | ||
48 | function getAccountActivityPubUrl (accountName: string) { | 48 | function getLocalAccountActivityPubUrl (accountName: string) { |
49 | return WEBSERVER.URL + '/accounts/' + accountName | 49 | return WEBSERVER.URL + '/accounts/' + accountName |
50 | } | 50 | } |
51 | 51 | ||
52 | function getAbuseActivityPubUrl (abuse: MAbuseId) { | 52 | function getLocalAbuseActivityPubUrl (abuse: MAbuseId) { |
53 | return WEBSERVER.URL + '/admin/abuses/' + abuse.id | 53 | return WEBSERVER.URL + '/admin/abuses/' + abuse.id |
54 | } | 54 | } |
55 | 55 | ||
56 | function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 56 | function 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 | ||
60 | function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 60 | function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) { |
61 | return byActor.url + '/likes/' + video.id | 61 | return byActor.url + '/likes/' + video.id |
62 | } | 62 | } |
63 | 63 | ||
64 | function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 64 | function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) { |
65 | return byActor.url + '/dislikes/' + video.id | 65 | return byActor.url + '/dislikes/' + video.id |
66 | } | 66 | } |
67 | 67 | ||
68 | function getVideoSharesActivityPubUrl (video: MVideoUrl) { | 68 | function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) { |
69 | return video.url + '/announces' | 69 | return video.url + '/announces' |
70 | } | 70 | } |
71 | 71 | ||
72 | function getVideoCommentsActivityPubUrl (video: MVideoUrl) { | 72 | function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) { |
73 | return video.url + '/comments' | 73 | return video.url + '/comments' |
74 | } | 74 | } |
75 | 75 | ||
76 | function getVideoLikesActivityPubUrl (video: MVideoUrl) { | 76 | function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) { |
77 | return video.url + '/likes' | 77 | return video.url + '/likes' |
78 | } | 78 | } |
79 | 79 | ||
80 | function getVideoDislikesActivityPubUrl (video: MVideoUrl) { | 80 | function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) { |
81 | return video.url + '/dislikes' | 81 | return video.url + '/dislikes' |
82 | } | 82 | } |
83 | 83 | ||
84 | function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) { | 84 | function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) { |
85 | return follower.url + '/follows/' + following.id | 85 | return follower.url + '/follows/' + following.id |
86 | } | 86 | } |
87 | 87 | ||
88 | function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) { | 88 | function 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 | ||
95 | function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) { | 95 | function 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 | ||
99 | function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) { | 99 | function 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 | ||
115 | export { | 115 | export { |
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 | } |