]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
Add check constraints live tests
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
1 import { WEBSERVER } from '../../initializers/constants'
2 import {
3 MActor,
4 MActorFollowActors,
5 MActorId,
6 MActorUrl,
7 MCommentId,
8 MVideoId,
9 MVideoUrl,
10 MVideoUUID,
11 MAbuseId,
12 MVideoPlaylistElement
13 } from '../../types/models'
14 import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
15 import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
16 import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
17
18 function getVideoActivityPubUrl (video: MVideoUUID) {
19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
20 }
21
22 function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
24 }
25
26 function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
28 }
29
30 function getVideoCacheFileActivityPubUrl (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 getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
38 }
39
40 function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
42 }
43
44 function getVideoChannelActivityPubUrl (videoChannelName: string) {
45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
46 }
47
48 function getAccountActivityPubUrl (accountName: string) {
49 return WEBSERVER.URL + '/accounts/' + accountName
50 }
51
52 function getAbuseActivityPubUrl (abuse: MAbuseId) {
53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
54 }
55
56 function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
58 }
59
60 function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
61 return byActor.url + '/likes/' + video.id
62 }
63
64 function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
65 return byActor.url + '/dislikes/' + video.id
66 }
67
68 function getVideoSharesActivityPubUrl (video: MVideoUrl) {
69 return video.url + '/announces'
70 }
71
72 function getVideoCommentsActivityPubUrl (video: MVideoUrl) {
73 return video.url + '/comments'
74 }
75
76 function getVideoLikesActivityPubUrl (video: MVideoUrl) {
77 return video.url + '/likes'
78 }
79
80 function getVideoDislikesActivityPubUrl (video: MVideoUrl) {
81 return video.url + '/dislikes'
82 }
83
84 function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
85 return follower.url + '/follows/' + following.id
86 }
87
88 function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
89 const follower = actorFollow.ActorFollower
90 const me = actorFollow.ActorFollowing
91
92 return follower.url + '/accepts/follows/' + me.id
93 }
94
95 function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) {
96 return follower.url + '/rejects/follows/' + following.id
97 }
98
99 function getVideoAnnounceActivityPubUrl (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 getVideoActivityPubUrl,
117 getVideoPlaylistElementActivityPubUrl,
118 getVideoPlaylistActivityPubUrl,
119 getVideoCacheStreamingPlaylistActivityPubUrl,
120 getVideoChannelActivityPubUrl,
121 getAccountActivityPubUrl,
122 getAbuseActivityPubUrl,
123 getActorFollowActivityPubUrl,
124 getActorFollowAcceptActivityPubUrl,
125 getVideoAnnounceActivityPubUrl,
126 getUpdateActivityPubUrl,
127 getUndoActivityPubUrl,
128 getVideoViewActivityPubUrl,
129 getVideoLikeActivityPubUrl,
130 getVideoDislikeActivityPubUrl,
131 getActorFollowRejectActivityPubUrl,
132 getVideoCommentActivityPubUrl,
133 getDeleteActivityPubUrl,
134 getVideoSharesActivityPubUrl,
135 getVideoCommentsActivityPubUrl,
136 getVideoLikesActivityPubUrl,
137 getVideoDislikesActivityPubUrl,
138 getVideoCacheFileActivityPubUrl
139 }