]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
Fix video import CLI script
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
1 import { WEBSERVER } from '../../initializers/constants'
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 { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
9 import { VideoPlaylistModel } from '../../models/video/video-playlist'
10
11 function getVideoActivityPubUrl (video: VideoModel) {
12 return WEBSERVER.URL + '/videos/watch/' + video.uuid
13 }
14
15 function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
16 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
17 }
18
19 function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
20 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
21 }
22
23 function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
24 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
25
26 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
27 }
28
29 function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
30 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
31 }
32
33 function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
34 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
35 }
36
37 function getVideoChannelActivityPubUrl (videoChannelName: string) {
38 return WEBSERVER.URL + '/video-channels/' + videoChannelName
39 }
40
41 function getAccountActivityPubUrl (accountName: string) {
42 return WEBSERVER.URL + '/accounts/' + accountName
43 }
44
45 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
46 return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
47 }
48
49 function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
50 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
51 }
52
53 function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
54 return byActor.url + '/likes/' + video.id
55 }
56
57 function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
58 return byActor.url + '/dislikes/' + video.id
59 }
60
61 function getVideoSharesActivityPubUrl (video: VideoModel) {
62 return video.url + '/announces'
63 }
64
65 function getVideoCommentsActivityPubUrl (video: VideoModel) {
66 return video.url + '/comments'
67 }
68
69 function getVideoLikesActivityPubUrl (video: VideoModel) {
70 return video.url + '/likes'
71 }
72
73 function getVideoDislikesActivityPubUrl (video: VideoModel) {
74 return video.url + '/dislikes'
75 }
76
77 function getActorFollowActivityPubUrl (follower: ActorModel, following: ActorModel) {
78 return follower.url + '/follows/' + following.id
79 }
80
81 function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
82 const follower = actorFollow.ActorFollower
83 const me = actorFollow.ActorFollowing
84
85 return follower.url + '/accepts/follows/' + me.id
86 }
87
88 function getActorFollowRejectActivityPubUrl (follower: ActorModel, following: ActorModel) {
89 return follower.url + '/rejects/follows/' + following.id
90 }
91
92 function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) {
93 return video.url + '/announces/' + byActor.id
94 }
95
96 function getDeleteActivityPubUrl (originalUrl: string) {
97 return originalUrl + '/delete'
98 }
99
100 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
101 return originalUrl + '/updates/' + updatedAt
102 }
103
104 function getUndoActivityPubUrl (originalUrl: string) {
105 return originalUrl + '/undo'
106 }
107
108 export {
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
132 }