]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
Merge branch 'release/2.3.0' into develop
[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 } from '../../types/models'
13 import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
14 import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
15 import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
16
17 function getVideoActivityPubUrl (video: MVideoUUID) {
18 return WEBSERVER.URL + '/videos/watch/' + video.uuid
19 }
20
21 function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
22 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
23 }
24
25 function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, video: MVideoUUID) {
26 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
27 }
28
29 function getVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) {
30 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
31
32 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
33 }
34
35 function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
36 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
37 }
38
39 function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
40 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
41 }
42
43 function getVideoChannelActivityPubUrl (videoChannelName: string) {
44 return WEBSERVER.URL + '/video-channels/' + videoChannelName
45 }
46
47 function getAccountActivityPubUrl (accountName: string) {
48 return WEBSERVER.URL + '/accounts/' + accountName
49 }
50
51 function getAbuseActivityPubUrl (abuse: MAbuseId) {
52 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
53 }
54
55 function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
56 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
57 }
58
59 function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
60 return byActor.url + '/likes/' + video.id
61 }
62
63 function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
64 return byActor.url + '/dislikes/' + video.id
65 }
66
67 function getVideoSharesActivityPubUrl (video: MVideoUrl) {
68 return video.url + '/announces'
69 }
70
71 function getVideoCommentsActivityPubUrl (video: MVideoUrl) {
72 return video.url + '/comments'
73 }
74
75 function getVideoLikesActivityPubUrl (video: MVideoUrl) {
76 return video.url + '/likes'
77 }
78
79 function getVideoDislikesActivityPubUrl (video: MVideoUrl) {
80 return video.url + '/dislikes'
81 }
82
83 function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
84 return follower.url + '/follows/' + following.id
85 }
86
87 function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
88 const follower = actorFollow.ActorFollower
89 const me = actorFollow.ActorFollowing
90
91 return follower.url + '/accepts/follows/' + me.id
92 }
93
94 function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) {
95 return follower.url + '/rejects/follows/' + following.id
96 }
97
98 function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
99 return video.url + '/announces/' + byActor.id
100 }
101
102 function getDeleteActivityPubUrl (originalUrl: string) {
103 return originalUrl + '/delete'
104 }
105
106 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
107 return originalUrl + '/updates/' + updatedAt
108 }
109
110 function getUndoActivityPubUrl (originalUrl: string) {
111 return originalUrl + '/undo'
112 }
113
114 export {
115 getVideoActivityPubUrl,
116 getVideoPlaylistElementActivityPubUrl,
117 getVideoPlaylistActivityPubUrl,
118 getVideoCacheStreamingPlaylistActivityPubUrl,
119 getVideoChannelActivityPubUrl,
120 getAccountActivityPubUrl,
121 getAbuseActivityPubUrl,
122 getActorFollowActivityPubUrl,
123 getActorFollowAcceptActivityPubUrl,
124 getVideoAnnounceActivityPubUrl,
125 getUpdateActivityPubUrl,
126 getUndoActivityPubUrl,
127 getVideoViewActivityPubUrl,
128 getVideoLikeActivityPubUrl,
129 getVideoDislikeActivityPubUrl,
130 getActorFollowRejectActivityPubUrl,
131 getVideoCommentActivityPubUrl,
132 getDeleteActivityPubUrl,
133 getVideoSharesActivityPubUrl,
134 getVideoCommentsActivityPubUrl,
135 getVideoLikesActivityPubUrl,
136 getVideoDislikesActivityPubUrl,
137 getVideoCacheFileActivityPubUrl
138 }