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