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