]>
Commit | Line | Data |
---|---|---|
74dc3bca | 1 | import { WEBSERVER } from '../../initializers/constants' |
453e83ea C |
2 | import { |
3 | MActor, | |
4 | MActorFollowActors, | |
5 | MActorId, | |
6 | MActorUrl, | |
7 | MCommentId, | |
453e83ea C |
8 | MVideoId, |
9 | MVideoUrl, | |
d95d1559 | 10 | MVideoUUID, |
37190663 C |
11 | MAbuseId, |
12 | MVideoPlaylistElement | |
26d6bf65 C |
13 | } from '../../types/models' |
14 | import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' | |
15 | import { MVideoFileVideoUUID } from '../../types/models/video/video-file' | |
16 | import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' | |
453e83ea C |
17 | |
18 | function getVideoActivityPubUrl (video: MVideoUUID) { | |
6dd9de95 | 19 | return WEBSERVER.URL + '/videos/watch/' + video.uuid |
892211e8 C |
20 | } |
21 | ||
453e83ea | 22 | function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { |
6dd9de95 | 23 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid |
418d092a C |
24 | } |
25 | ||
37190663 C |
26 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) { |
27 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id | |
418d092a C |
28 | } |
29 | ||
453e83ea | 30 | function getVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) { |
d05be4d9 | 31 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' |
c48e82b5 | 32 | |
6dd9de95 | 33 | return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` |
c48e82b5 C |
34 | } |
35 | ||
453e83ea | 36 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) { |
6dd9de95 | 37 | return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` |
09209296 C |
38 | } |
39 | ||
453e83ea | 40 | function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) { |
6dd9de95 | 41 | return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id |
50d6de9c C |
42 | } |
43 | ||
8a19bee1 | 44 | function getVideoChannelActivityPubUrl (videoChannelName: string) { |
6dd9de95 | 45 | return WEBSERVER.URL + '/video-channels/' + videoChannelName |
892211e8 C |
46 | } |
47 | ||
48 | function getAccountActivityPubUrl (accountName: string) { | |
6dd9de95 | 49 | return WEBSERVER.URL + '/accounts/' + accountName |
892211e8 C |
50 | } |
51 | ||
d95d1559 C |
52 | function getAbuseActivityPubUrl (abuse: MAbuseId) { |
53 | return WEBSERVER.URL + '/admin/abuses/' + abuse.id | |
892211e8 C |
54 | } |
55 | ||
453e83ea | 56 | function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) { |
5c6d985f | 57 | return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() |
40ff5707 C |
58 | } |
59 | ||
453e83ea | 60 | function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { |
50d6de9c | 61 | return byActor.url + '/likes/' + video.id |
0032ebe9 C |
62 | } |
63 | ||
453e83ea | 64 | function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { |
50d6de9c | 65 | return byActor.url + '/dislikes/' + video.id |
0032ebe9 C |
66 | } |
67 | ||
453e83ea | 68 | function getVideoSharesActivityPubUrl (video: MVideoUrl) { |
46531a0a C |
69 | return video.url + '/announces' |
70 | } | |
71 | ||
453e83ea | 72 | function getVideoCommentsActivityPubUrl (video: MVideoUrl) { |
46531a0a C |
73 | return video.url + '/comments' |
74 | } | |
75 | ||
453e83ea | 76 | function getVideoLikesActivityPubUrl (video: MVideoUrl) { |
46531a0a C |
77 | return video.url + '/likes' |
78 | } | |
79 | ||
453e83ea | 80 | function getVideoDislikesActivityPubUrl (video: MVideoUrl) { |
46531a0a C |
81 | return video.url + '/dislikes' |
82 | } | |
83 | ||
453e83ea | 84 | function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) { |
5b9c965d | 85 | return follower.url + '/follows/' + following.id |
892211e8 C |
86 | } |
87 | ||
453e83ea | 88 | function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) { |
50d6de9c C |
89 | const follower = actorFollow.ActorFollower |
90 | const me = actorFollow.ActorFollowing | |
892211e8 | 91 | |
4e50b6a1 | 92 | return follower.url + '/accepts/follows/' + me.id |
892211e8 C |
93 | } |
94 | ||
453e83ea | 95 | function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) { |
5b9c965d C |
96 | return follower.url + '/rejects/follows/' + following.id |
97 | } | |
98 | ||
453e83ea | 99 | function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) { |
5c6d985f | 100 | return video.url + '/announces/' + byActor.id |
892211e8 C |
101 | } |
102 | ||
c3badc81 C |
103 | function getDeleteActivityPubUrl (originalUrl: string) { |
104 | return originalUrl + '/delete' | |
105 | } | |
106 | ||
892211e8 | 107 | function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { |
4e50b6a1 | 108 | return originalUrl + '/updates/' + updatedAt |
892211e8 C |
109 | } |
110 | ||
111 | function getUndoActivityPubUrl (originalUrl: string) { | |
112 | return originalUrl + '/undo' | |
113 | } | |
114 | ||
115 | export { | |
116 | getVideoActivityPubUrl, | |
418d092a C |
117 | getVideoPlaylistElementActivityPubUrl, |
118 | getVideoPlaylistActivityPubUrl, | |
09209296 | 119 | getVideoCacheStreamingPlaylistActivityPubUrl, |
892211e8 C |
120 | getVideoChannelActivityPubUrl, |
121 | getAccountActivityPubUrl, | |
d95d1559 | 122 | getAbuseActivityPubUrl, |
50d6de9c C |
123 | getActorFollowActivityPubUrl, |
124 | getActorFollowAcceptActivityPubUrl, | |
5c6d985f | 125 | getVideoAnnounceActivityPubUrl, |
892211e8 | 126 | getUpdateActivityPubUrl, |
40ff5707 | 127 | getUndoActivityPubUrl, |
0032ebe9 C |
128 | getVideoViewActivityPubUrl, |
129 | getVideoLikeActivityPubUrl, | |
bf1f6508 | 130 | getVideoDislikeActivityPubUrl, |
5b9c965d | 131 | getActorFollowRejectActivityPubUrl, |
c3badc81 | 132 | getVideoCommentActivityPubUrl, |
46531a0a C |
133 | getDeleteActivityPubUrl, |
134 | getVideoSharesActivityPubUrl, | |
135 | getVideoCommentsActivityPubUrl, | |
136 | getVideoLikesActivityPubUrl, | |
c48e82b5 C |
137 | getVideoDislikesActivityPubUrl, |
138 | getVideoCacheFileActivityPubUrl | |
892211e8 | 139 | } |