1 import { CONFIG } from '../../initializers'
2 import { ActorModel } from '../../models/activitypub/actor'
3 import { ActorFollowModel } from '../../models/activitypub/actor-follow'
4 import { VideoModel } from '../../models/video/video'
5 import { VideoAbuseModel } from '../../models/video/video-abuse'
6 import { VideoCommentModel } from '../../models/video/video-comment'
7 import { VideoFileModel } from '../../models/video/video-file'
8 import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'
9 import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
11 function getVideoActivityPubUrl (video: VideoModel) {
12 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
15 function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
16 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
18 return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
21 function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
22 return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}`
25 function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
26 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
29 function getVideoChannelActivityPubUrl (videoChannelName: string) {
30 return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
33 function getAccountActivityPubUrl (accountName: string) {
34 return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
37 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
38 return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
41 function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
42 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
45 function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
46 return byActor.url + '/likes/' + video.id
49 function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
50 return byActor.url + '/dislikes/' + video.id
53 function getVideoSharesActivityPubUrl (video: VideoModel) {
54 return video.url + '/announces'
57 function getVideoCommentsActivityPubUrl (video: VideoModel) {
58 return video.url + '/comments'
61 function getVideoLikesActivityPubUrl (video: VideoModel) {
62 return video.url + '/likes'
65 function getVideoDislikesActivityPubUrl (video: VideoModel) {
66 return video.url + '/dislikes'
69 function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
70 const me = actorFollow.ActorFollower
71 const following = actorFollow.ActorFollowing
73 return me.url + '/follows/' + following.id
76 function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
77 const follower = actorFollow.ActorFollower
78 const me = actorFollow.ActorFollowing
80 return follower.url + '/accepts/follows/' + me.id
83 function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) {
84 return video.url + '/announces/' + byActor.id
87 function getDeleteActivityPubUrl (originalUrl: string) {
88 return originalUrl + '/delete'
91 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
92 return originalUrl + '/updates/' + updatedAt
95 function getUndoActivityPubUrl (originalUrl: string) {
96 return originalUrl + '/undo'
100 getVideoActivityPubUrl,
101 getVideoCacheStreamingPlaylistActivityPubUrl,
102 getVideoChannelActivityPubUrl,
103 getAccountActivityPubUrl,
104 getVideoAbuseActivityPubUrl,
105 getActorFollowActivityPubUrl,
106 getActorFollowAcceptActivityPubUrl,
107 getVideoAnnounceActivityPubUrl,
108 getUpdateActivityPubUrl,
109 getUndoActivityPubUrl,
110 getVideoViewActivityPubUrl,
111 getVideoLikeActivityPubUrl,
112 getVideoDislikeActivityPubUrl,
113 getVideoCommentActivityPubUrl,
114 getDeleteActivityPubUrl,
115 getVideoSharesActivityPubUrl,
116 getVideoCommentsActivityPubUrl,
117 getVideoLikesActivityPubUrl,
118 getVideoDislikesActivityPubUrl,
119 getVideoCacheFileActivityPubUrl