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