1 import { WEBSERVER } from '../../initializers/constants'
2 import { VideoModel } from '../../models/video/video'
3 import { VideoAbuseModel } from '../../models/video/video-abuse'
4 import { VideoCommentModel } from '../../models/video/video-comment'
5 import { VideoFileModel } from '../../models/video/video-file'
6 import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
7 import { VideoPlaylistModel } from '../../models/video/video-playlist'
8 import { ActorModelOnly, ActorModelUrl } from '../../typings/models'
9 import { ActorFollowModelLight } from '../../typings/models/actor-follow'
11 function getVideoActivityPubUrl (video: VideoModel) {
12 return WEBSERVER.URL + '/videos/watch/' + video.uuid
15 function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
16 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
19 function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
20 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
23 function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
24 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
26 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
29 function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
30 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
33 function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
34 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
37 function getVideoChannelActivityPubUrl (videoChannelName: string) {
38 return WEBSERVER.URL + '/video-channels/' + videoChannelName
41 function getAccountActivityPubUrl (accountName: string) {
42 return WEBSERVER.URL + '/accounts/' + accountName
45 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
46 return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
49 function getVideoViewActivityPubUrl (byActor: ActorModelUrl, video: VideoModel) {
50 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
53 function getVideoLikeActivityPubUrl (byActor: ActorModelUrl, video: VideoModel | { id: number }) {
54 return byActor.url + '/likes/' + video.id
57 function getVideoDislikeActivityPubUrl (byActor: ActorModelUrl, video: VideoModel | { id: number }) {
58 return byActor.url + '/dislikes/' + video.id
61 function getVideoSharesActivityPubUrl (video: VideoModel) {
62 return video.url + '/announces'
65 function getVideoCommentsActivityPubUrl (video: VideoModel) {
66 return video.url + '/comments'
69 function getVideoLikesActivityPubUrl (video: VideoModel) {
70 return video.url + '/likes'
73 function getVideoDislikesActivityPubUrl (video: VideoModel) {
74 return video.url + '/dislikes'
77 function getActorFollowActivityPubUrl (follower: ActorModelOnly, following: ActorModelOnly) {
78 return follower.url + '/follows/' + following.id
81 function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModelLight) {
82 const follower = actorFollow.ActorFollower
83 const me = actorFollow.ActorFollowing
85 return follower.url + '/accepts/follows/' + me.id
88 function getActorFollowRejectActivityPubUrl (follower: ActorModelOnly, following: ActorModelOnly) {
89 return follower.url + '/rejects/follows/' + following.id
92 function getVideoAnnounceActivityPubUrl (byActor: ActorModelOnly, video: VideoModel) {
93 return video.url + '/announces/' + byActor.id
96 function getDeleteActivityPubUrl (originalUrl: string) {
97 return originalUrl + '/delete'
100 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
101 return originalUrl + '/updates/' + updatedAt
104 function getUndoActivityPubUrl (originalUrl: string) {
105 return originalUrl + '/undo'
109 getVideoActivityPubUrl,
110 getVideoPlaylistElementActivityPubUrl,
111 getVideoPlaylistActivityPubUrl,
112 getVideoCacheStreamingPlaylistActivityPubUrl,
113 getVideoChannelActivityPubUrl,
114 getAccountActivityPubUrl,
115 getVideoAbuseActivityPubUrl,
116 getActorFollowActivityPubUrl,
117 getActorFollowAcceptActivityPubUrl,
118 getVideoAnnounceActivityPubUrl,
119 getUpdateActivityPubUrl,
120 getUndoActivityPubUrl,
121 getVideoViewActivityPubUrl,
122 getVideoLikeActivityPubUrl,
123 getVideoDislikeActivityPubUrl,
124 getActorFollowRejectActivityPubUrl,
125 getVideoCommentActivityPubUrl,
126 getDeleteActivityPubUrl,
127 getVideoSharesActivityPubUrl,
128 getVideoCommentsActivityPubUrl,
129 getVideoLikesActivityPubUrl,
130 getVideoDislikesActivityPubUrl,
131 getVideoCacheFileActivityPubUrl