]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/activitypub/url.ts
Update translations
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
... / ...
CommitLineData
1import { WEBSERVER } from '../../initializers/constants'
2import {
3 MActor,
4 MActorFollowActors,
5 MActorId,
6 MActorUrl,
7 MCommentId,
8 MVideoId,
9 MVideoUrl,
10 MVideoUUID,
11 MAbuseId,
12 MVideoPlaylistElement
13} from '../../types/models'
14import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
15import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
16import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
17
18function getVideoActivityPubUrl (video: MVideoUUID) {
19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
20}
21
22function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
24}
25
26function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
28}
29
30function 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
36function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
38}
39
40function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
42}
43
44function getVideoChannelActivityPubUrl (videoChannelName: string) {
45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
46}
47
48function getAccountActivityPubUrl (accountName: string) {
49 return WEBSERVER.URL + '/accounts/' + accountName
50}
51
52function getAbuseActivityPubUrl (abuse: MAbuseId) {
53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
54}
55
56function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
58}
59
60function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
61 return byActor.url + '/likes/' + video.id
62}
63
64function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
65 return byActor.url + '/dislikes/' + video.id
66}
67
68function getVideoSharesActivityPubUrl (video: MVideoUrl) {
69 return video.url + '/announces'
70}
71
72function getVideoCommentsActivityPubUrl (video: MVideoUrl) {
73 return video.url + '/comments'
74}
75
76function getVideoLikesActivityPubUrl (video: MVideoUrl) {
77 return video.url + '/likes'
78}
79
80function getVideoDislikesActivityPubUrl (video: MVideoUrl) {
81 return video.url + '/dislikes'
82}
83
84function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
85 return follower.url + '/follows/' + following.id
86}
87
88function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
89 const follower = actorFollow.ActorFollower
90 const me = actorFollow.ActorFollowing
91
92 return follower.url + '/accepts/follows/' + me.id
93}
94
95function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) {
96 return follower.url + '/rejects/follows/' + following.id
97}
98
99function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
100 return video.url + '/announces/' + byActor.id
101}
102
103function getDeleteActivityPubUrl (originalUrl: string) {
104 return originalUrl + '/delete'
105}
106
107function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
108 return originalUrl + '/updates/' + updatedAt
109}
110
111function getUndoActivityPubUrl (originalUrl: string) {
112 return originalUrl + '/undo'
113}
114
115export {
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}