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'
9 function getVideoActivityPubUrl (video: VideoModel) {
10 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
13 function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
14 const suffixFPS = videoFile.fps ? '-' + videoFile.fps : ''
16 return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
19 function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
20 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
23 function getVideoChannelActivityPubUrl (videoChannelName: string) {
24 return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
27 function getAccountActivityPubUrl (accountName: string) {
28 return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
31 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
32 return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
35 function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
36 return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString()
39 function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
40 return byActor.url + '/likes/' + video.id
43 function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
44 return byActor.url + '/dislikes/' + video.id
47 function getVideoSharesActivityPubUrl (video: VideoModel) {
48 return video.url + '/announces'
51 function getVideoCommentsActivityPubUrl (video: VideoModel) {
52 return video.url + '/comments'
55 function getVideoLikesActivityPubUrl (video: VideoModel) {
56 return video.url + '/likes'
59 function getVideoDislikesActivityPubUrl (video: VideoModel) {
60 return video.url + '/dislikes'
63 function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
64 const me = actorFollow.ActorFollower
65 const following = actorFollow.ActorFollowing
67 return me.url + '/follows/' + following.id
70 function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
71 const follower = actorFollow.ActorFollower
72 const me = actorFollow.ActorFollowing
74 return follower.url + '/accepts/follows/' + me.id
77 function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) {
78 return originalUrl + '/announces/' + byActor.id
81 function getDeleteActivityPubUrl (originalUrl: string) {
82 return originalUrl + '/delete'
85 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
86 return originalUrl + '/updates/' + updatedAt
89 function getUndoActivityPubUrl (originalUrl: string) {
90 return originalUrl + '/undo'
94 getVideoActivityPubUrl,
95 getVideoChannelActivityPubUrl,
96 getAccountActivityPubUrl,
97 getVideoAbuseActivityPubUrl,
98 getActorFollowActivityPubUrl,
99 getActorFollowAcceptActivityPubUrl,
100 getAnnounceActivityPubUrl,
101 getUpdateActivityPubUrl,
102 getUndoActivityPubUrl,
103 getVideoViewActivityPubUrl,
104 getVideoLikeActivityPubUrl,
105 getVideoDislikeActivityPubUrl,
106 getVideoCommentActivityPubUrl,
107 getDeleteActivityPubUrl,
108 getVideoSharesActivityPubUrl,
109 getVideoCommentsActivityPubUrl,
110 getVideoLikesActivityPubUrl,
111 getVideoDislikesActivityPubUrl,
112 getVideoCacheFileActivityPubUrl