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