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