]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/url.ts
Fix incorrect IDs in AP federation
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
CommitLineData
74dc3bca 1import { WEBSERVER } from '../../initializers/constants'
453e83ea 2import {
de94ac86 3 MAbuseId,
453e83ea
C
4 MActor,
5 MActorFollowActors,
6 MActorId,
7 MActorUrl,
8 MCommentId,
453e83ea 9 MVideoId,
de94ac86 10 MVideoPlaylistElement,
453e83ea 11 MVideoUrl,
de94ac86 12 MVideoUUID
26d6bf65 13} from '../../types/models'
26d6bf65 14import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
de94ac86 15import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
26d6bf65 16import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist'
453e83ea 17
de94ac86 18function getLocalVideoActivityPubUrl (video: MVideoUUID) {
6dd9de95 19 return WEBSERVER.URL + '/videos/watch/' + video.uuid
892211e8
C
20}
21
de94ac86 22function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) {
6dd9de95 23 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
418d092a
C
24}
25
de94ac86 26function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) {
37190663 27 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id
418d092a
C
28}
29
de94ac86 30function getLocalVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) {
d05be4d9 31 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
c48e82b5 32
6dd9de95 33 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
c48e82b5
C
34}
35
de94ac86 36function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) {
6dd9de95 37 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
09209296
C
38}
39
de94ac86 40function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
6dd9de95 41 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
50d6de9c
C
42}
43
de94ac86 44function getLocalVideoChannelActivityPubUrl (videoChannelName: string) {
6dd9de95 45 return WEBSERVER.URL + '/video-channels/' + videoChannelName
892211e8
C
46}
47
de94ac86 48function getLocalAccountActivityPubUrl (accountName: string) {
6dd9de95 49 return WEBSERVER.URL + '/accounts/' + accountName
892211e8
C
50}
51
de94ac86 52function getLocalAbuseActivityPubUrl (abuse: MAbuseId) {
d95d1559 53 return WEBSERVER.URL + '/admin/abuses/' + abuse.id
892211e8
C
54}
55
de94ac86 56function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) {
5c6d985f 57 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
40ff5707
C
58}
59
de94ac86 60function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
50d6de9c 61 return byActor.url + '/likes/' + video.id
0032ebe9
C
62}
63
de94ac86 64function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) {
50d6de9c 65 return byActor.url + '/dislikes/' + video.id
0032ebe9
C
66}
67
de94ac86 68function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) {
46531a0a
C
69 return video.url + '/announces'
70}
71
de94ac86 72function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) {
46531a0a
C
73 return video.url + '/comments'
74}
75
de94ac86 76function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) {
46531a0a
C
77 return video.url + '/likes'
78}
79
de94ac86 80function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) {
46531a0a
C
81 return video.url + '/dislikes'
82}
83
de94ac86 84function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) {
5b9c965d 85 return follower.url + '/follows/' + following.id
892211e8
C
86}
87
de94ac86 88function getLocalActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) {
50d6de9c
C
89 const follower = actorFollow.ActorFollower
90 const me = actorFollow.ActorFollowing
892211e8 91
de94ac86 92 return WEBSERVER.URL + '/accepts/follows/' + follower.id + '/' + me.id
892211e8
C
93}
94
de94ac86
C
95function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) {
96 return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id
5b9c965d
C
97}
98
de94ac86 99function getLocalVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) {
5c6d985f 100 return video.url + '/announces/' + byActor.id
892211e8
C
101}
102
c3badc81
C
103function getDeleteActivityPubUrl (originalUrl: string) {
104 return originalUrl + '/delete'
105}
106
892211e8 107function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
4e50b6a1 108 return originalUrl + '/updates/' + updatedAt
892211e8
C
109}
110
111function getUndoActivityPubUrl (originalUrl: string) {
112 return originalUrl + '/undo'
113}
114
115export {
de94ac86
C
116 getLocalVideoActivityPubUrl,
117 getLocalVideoPlaylistActivityPubUrl,
118 getLocalVideoPlaylistElementActivityPubUrl,
119 getLocalVideoCacheFileActivityPubUrl,
120 getLocalVideoCacheStreamingPlaylistActivityPubUrl,
121 getLocalVideoCommentActivityPubUrl,
122 getLocalVideoChannelActivityPubUrl,
123 getLocalAccountActivityPubUrl,
124 getLocalAbuseActivityPubUrl,
125 getLocalActorFollowActivityPubUrl,
126 getLocalActorFollowAcceptActivityPubUrl,
127 getLocalVideoAnnounceActivityPubUrl,
892211e8 128 getUpdateActivityPubUrl,
40ff5707 129 getUndoActivityPubUrl,
de94ac86
C
130 getVideoLikeActivityPubUrlByLocalActor,
131 getLocalVideoViewActivityPubUrl,
132 getVideoDislikeActivityPubUrlByLocalActor,
133 getLocalActorFollowRejectActivityPubUrl,
46531a0a 134 getDeleteActivityPubUrl,
de94ac86
C
135 getLocalVideoSharesActivityPubUrl,
136 getLocalVideoCommentsActivityPubUrl,
137 getLocalVideoLikesActivityPubUrl,
138 getLocalVideoDislikesActivityPubUrl,
139
892211e8 140}