]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/activitypub/url.ts
fix colspan for user view of reports
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
... / ...
CommitLineData
1import { WEBSERVER } from '../../initializers/constants'
2import {
3 MAbuseId,
4 MActor,
5 MActorFollowActors,
6 MActorId,
7 MActorUrl,
8 MCommentId,
9 MVideoId,
10 MVideoPlaylistElement,
11 MVideoUrl,
12 MVideoUUID
13} from '../../types/models'
14import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
15import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
16import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
17
18function getLocalVideoActivityPubUrl (video: MVideoUUID) {
19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
20}
21
22function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
24}
25
26function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
28}
29
30function 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
36function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
38}
39
40function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
42}
43
44function getLocalVideoChannelActivityPubUrl (videoChannelName: string) {
45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
46}
47
48function getLocalAccountActivityPubUrl (accountName: string) {
49 return WEBSERVER.URL + '/accounts/' + accountName
50}
51
52function getLocalAbuseActivityPubUrl (abuse: MAbuseId) {
53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
54}
55
56function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
58}
59
60function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
61 return byActor.url + '/likes/' + video.id
62}
63
64function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
65 return byActor.url + '/dislikes/' + video.id
66}
67
68function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) {
69 return video.url + '/announces'
70}
71
72function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) {
73 return video.url + '/comments'
74}
75
76function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) {
77 return video.url + '/likes'
78}
79
80function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) {
81 return video.url + '/dislikes'
82}
83
84function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
85 return follower.url + '/follows/' + following.id
86}
87
88function 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
95function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) {
96 return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id
97}
98
99function getLocalVideoAnnounceActivityPubUrl (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 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}