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