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