1 import { WEBSERVER } from '../../initializers/constants'
11 MVideoPlaylistElement,
14 } from '../../types/models'
15 import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
16 import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
17 import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
19 function getLocalVideoActivityPubUrl (video: MVideoUUID) {
20 return WEBSERVER.URL + '/videos/watch/' + video.uuid
23 function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
24 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
27 function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
28 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
31 function getLocalVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) {
32 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
34 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
37 function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
38 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
41 function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
42 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
45 function getLocalVideoChannelActivityPubUrl (videoChannelName: string) {
46 return WEBSERVER.URL + '/video-channels/' + videoChannelName
49 function getLocalAccountActivityPubUrl (accountName: string) {
50 return WEBSERVER.URL + '/accounts/' + accountName
53 function getLocalAbuseActivityPubUrl (abuse: MAbuseId) {
54 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
57 function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
58 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
61 function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
62 return byActor.url + '/likes/' + video.id
65 function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
66 return byActor.url + '/dislikes/' + video.id
69 function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) {
70 return video.url + '/announces'
73 function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) {
74 return video.url + '/comments'
77 function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) {
78 return video.url + '/likes'
81 function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) {
82 return video.url + '/dislikes'
85 function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
86 return follower.url + '/follows/' + following.id
89 function getLocalActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
90 const follower = actorFollow.ActorFollower
91 const me = actorFollow.ActorFollowing
93 return WEBSERVER.URL + '/accepts/follows/' + follower.id + '/' + me.id
96 function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) {
97 return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id
100 function getLocalVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
101 return video.url + '/announces/' + byActor.id
104 function getDeleteActivityPubUrl (originalUrl: string) {
105 return originalUrl + '/delete'
108 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
109 return originalUrl + '/updates/' + updatedAt
112 function getUndoActivityPubUrl (originalUrl: string) {
113 return originalUrl + '/undo'
116 // ---------------------------------------------------------------------------
118 function getAbuseTargetUrl (abuse: MAbuseFull) {
119 return abuse.VideoAbuse?.Video?.url ||
120 abuse.VideoCommentAbuse?.VideoComment?.url ||
121 abuse.FlaggedAccount.Actor.url
125 getLocalVideoActivityPubUrl,
126 getLocalVideoPlaylistActivityPubUrl,
127 getLocalVideoPlaylistElementActivityPubUrl,
128 getLocalVideoCacheFileActivityPubUrl,
129 getLocalVideoCacheStreamingPlaylistActivityPubUrl,
130 getLocalVideoCommentActivityPubUrl,
131 getLocalVideoChannelActivityPubUrl,
132 getLocalAccountActivityPubUrl,
133 getLocalAbuseActivityPubUrl,
134 getLocalActorFollowActivityPubUrl,
135 getLocalActorFollowAcceptActivityPubUrl,
136 getLocalVideoAnnounceActivityPubUrl,
137 getUpdateActivityPubUrl,
138 getUndoActivityPubUrl,
139 getVideoLikeActivityPubUrlByLocalActor,
140 getLocalVideoViewActivityPubUrl,
141 getVideoDislikeActivityPubUrlByLocalActor,
142 getLocalActorFollowRejectActivityPubUrl,
143 getDeleteActivityPubUrl,
144 getLocalVideoSharesActivityPubUrl,
145 getLocalVideoCommentsActivityPubUrl,
146 getLocalVideoLikesActivityPubUrl,
147 getLocalVideoDislikesActivityPubUrl,