]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
Try to speed up server tests
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
1 import { WEBSERVER } from '../../initializers/constants'
2 import {
3 MAbuseId,
4 MActor,
5 MActorFollowActors,
6 MActorId,
7 MActorUrl,
8 MCommentId,
9 MVideoId,
10 MVideoPlaylistElement,
11 MVideoUrl,
12 MVideoUUID
13 } from '../../types/models'
14 import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
15 import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
16 import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
17
18 function getLocalVideoActivityPubUrl (video: MVideoUUID) {
19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
20 }
21
22 function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
24 }
25
26 function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
28 }
29
30 function getLocalVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) {
31 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
32
33 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
34 }
35
36 function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
38 }
39
40 function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
42 }
43
44 function getLocalVideoChannelActivityPubUrl (videoChannelName: string) {
45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
46 }
47
48 function getLocalAccountActivityPubUrl (accountName: string) {
49 return WEBSERVER.URL + '/accounts/' + accountName
50 }
51
52 function getLocalAbuseActivityPubUrl (abuse: MAbuseId) {
53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
54 }
55
56 function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
58 }
59
60 function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
61 return byActor.url + '/likes/' + video.id
62 }
63
64 function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
65 return byActor.url + '/dislikes/' + video.id
66 }
67
68 function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) {
69 return video.url + '/announces'
70 }
71
72 function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) {
73 return video.url + '/comments'
74 }
75
76 function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) {
77 return video.url + '/likes'
78 }
79
80 function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) {
81 return video.url + '/dislikes'
82 }
83
84 function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
85 return follower.url + '/follows/' + following.id
86 }
87
88 function getLocalActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
89 const follower = actorFollow.ActorFollower
90 const me = actorFollow.ActorFollowing
91
92 return WEBSERVER.URL + '/accepts/follows/' + follower.id + '/' + me.id
93 }
94
95 function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) {
96 return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id
97 }
98
99 function getLocalVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
100 return video.url + '/announces/' + byActor.id
101 }
102
103 function getDeleteActivityPubUrl (originalUrl: string) {
104 return originalUrl + '/delete'
105 }
106
107 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
108 return originalUrl + '/updates/' + updatedAt
109 }
110
111 function getUndoActivityPubUrl (originalUrl: string) {
112 return originalUrl + '/undo'
113 }
114
115 export {
116 getLocalVideoActivityPubUrl,
117 getLocalVideoPlaylistActivityPubUrl,
118 getLocalVideoPlaylistElementActivityPubUrl,
119 getLocalVideoCacheFileActivityPubUrl,
120 getLocalVideoCacheStreamingPlaylistActivityPubUrl,
121 getLocalVideoCommentActivityPubUrl,
122 getLocalVideoChannelActivityPubUrl,
123 getLocalAccountActivityPubUrl,
124 getLocalAbuseActivityPubUrl,
125 getLocalActorFollowActivityPubUrl,
126 getLocalActorFollowAcceptActivityPubUrl,
127 getLocalVideoAnnounceActivityPubUrl,
128 getUpdateActivityPubUrl,
129 getUndoActivityPubUrl,
130 getVideoLikeActivityPubUrlByLocalActor,
131 getLocalVideoViewActivityPubUrl,
132 getVideoDislikeActivityPubUrlByLocalActor,
133 getLocalActorFollowRejectActivityPubUrl,
134 getDeleteActivityPubUrl,
135 getLocalVideoSharesActivityPubUrl,
136 getLocalVideoCommentsActivityPubUrl,
137 getLocalVideoLikesActivityPubUrl,
138 getLocalVideoDislikesActivityPubUrl
139 }