]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/url.ts
Move config in its own file
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
CommitLineData
6dd9de95 1import { WEBSERVER } from '../../initializers'
50d6de9c
C
2import { ActorModel } from '../../models/activitypub/actor'
3import { ActorFollowModel } from '../../models/activitypub/actor-follow'
3fd3ab2d
C
4import { VideoModel } from '../../models/video/video'
5import { VideoAbuseModel } from '../../models/video/video-abuse'
bf1f6508 6import { VideoCommentModel } from '../../models/video/video-comment'
c48e82b5 7import { VideoFileModel } from '../../models/video/video-file'
09209296 8import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
418d092a 9import { VideoPlaylistModel } from '../../models/video/video-playlist'
892211e8 10
3fd3ab2d 11function getVideoActivityPubUrl (video: VideoModel) {
6dd9de95 12 return WEBSERVER.URL + '/videos/watch/' + video.uuid
892211e8
C
13}
14
418d092a 15function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
6dd9de95 16 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
418d092a
C
17}
18
19function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
6dd9de95 20 return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
418d092a
C
21}
22
c48e82b5 23function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
d05be4d9 24 const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
c48e82b5 25
6dd9de95 26 return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
c48e82b5
C
27}
28
09209296 29function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
6dd9de95 30 return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}`
09209296
C
31}
32
bf1f6508 33function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
6dd9de95 34 return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
50d6de9c
C
35}
36
8a19bee1 37function getVideoChannelActivityPubUrl (videoChannelName: string) {
6dd9de95 38 return WEBSERVER.URL + '/video-channels/' + videoChannelName
892211e8
C
39}
40
41function getAccountActivityPubUrl (accountName: string) {
6dd9de95 42 return WEBSERVER.URL + '/accounts/' + accountName
892211e8
C
43}
44
3fd3ab2d 45function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
6dd9de95 46 return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
892211e8
C
47}
48
50d6de9c 49function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
5c6d985f 50 return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
40ff5707
C
51}
52
5c6d985f 53function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
50d6de9c 54 return byActor.url + '/likes/' + video.id
0032ebe9
C
55}
56
5c6d985f 57function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
50d6de9c 58 return byActor.url + '/dislikes/' + video.id
0032ebe9
C
59}
60
46531a0a
C
61function getVideoSharesActivityPubUrl (video: VideoModel) {
62 return video.url + '/announces'
63}
64
65function getVideoCommentsActivityPubUrl (video: VideoModel) {
66 return video.url + '/comments'
67}
68
69function getVideoLikesActivityPubUrl (video: VideoModel) {
70 return video.url + '/likes'
71}
72
73function getVideoDislikesActivityPubUrl (video: VideoModel) {
74 return video.url + '/dislikes'
75}
76
5b9c965d
C
77function getActorFollowActivityPubUrl (follower: ActorModel, following: ActorModel) {
78 return follower.url + '/follows/' + following.id
892211e8
C
79}
80
50d6de9c
C
81function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
82 const follower = actorFollow.ActorFollower
83 const me = actorFollow.ActorFollowing
892211e8 84
4e50b6a1 85 return follower.url + '/accepts/follows/' + me.id
892211e8
C
86}
87
5b9c965d
C
88function getActorFollowRejectActivityPubUrl (follower: ActorModel, following: ActorModel) {
89 return follower.url + '/rejects/follows/' + following.id
90}
91
5c6d985f
C
92function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) {
93 return video.url + '/announces/' + byActor.id
892211e8
C
94}
95
c3badc81
C
96function getDeleteActivityPubUrl (originalUrl: string) {
97 return originalUrl + '/delete'
98}
99
892211e8 100function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
4e50b6a1 101 return originalUrl + '/updates/' + updatedAt
892211e8
C
102}
103
104function getUndoActivityPubUrl (originalUrl: string) {
105 return originalUrl + '/undo'
106}
107
108export {
109 getVideoActivityPubUrl,
418d092a
C
110 getVideoPlaylistElementActivityPubUrl,
111 getVideoPlaylistActivityPubUrl,
09209296 112 getVideoCacheStreamingPlaylistActivityPubUrl,
892211e8
C
113 getVideoChannelActivityPubUrl,
114 getAccountActivityPubUrl,
115 getVideoAbuseActivityPubUrl,
50d6de9c
C
116 getActorFollowActivityPubUrl,
117 getActorFollowAcceptActivityPubUrl,
5c6d985f 118 getVideoAnnounceActivityPubUrl,
892211e8 119 getUpdateActivityPubUrl,
40ff5707 120 getUndoActivityPubUrl,
0032ebe9
C
121 getVideoViewActivityPubUrl,
122 getVideoLikeActivityPubUrl,
bf1f6508 123 getVideoDislikeActivityPubUrl,
5b9c965d 124 getActorFollowRejectActivityPubUrl,
c3badc81 125 getVideoCommentActivityPubUrl,
46531a0a
C
126 getDeleteActivityPubUrl,
127 getVideoSharesActivityPubUrl,
128 getVideoCommentsActivityPubUrl,
129 getVideoLikesActivityPubUrl,
c48e82b5
C
130 getVideoDislikesActivityPubUrl,
131 getVideoCacheFileActivityPubUrl
892211e8 132}